/* SPDX-License-Identifier: LGPL-2.1-only OR BSD-3-Clause */
/******************************************************************************
 *
 * This file is provided under a dual license.  When you use or
 * distribute this software, you may choose to be licensed under
 * version 2.1 of the GNU Lesser General Public License
 * ("LGPLv2.1 License") or BSD License.
 *
 * LGPLv2.1 License
 *
 * Copyright(C) 2019 MediaTek Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of version 2.1 of the GNU Lesser General Public
 * License as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html for more
 * details.
 *
 * BSD LICENSE
 *
 * Copyright(C) 2019 MediaTek Inc.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 *  * Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *  * Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *  * Neither the name of the copyright holder nor the names of its
 *    contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 *****************************************************************************/

/*-----------------------------------------------------------------------------
 * $RCSfile: img_slideshow.h,v $
 * $Revision: #1 $
 * $Date: 2015/05/29 $
 * $Author: brianpc.huang $
 *
 * Description: Photo Slideshow Library Header file
 *---------------------------------------------------------------------------*/

#ifndef _IMG_SLIDESHOW_H_
#define _IMG_SLIDESHOW_H_

#include "u_common.h"
#include "x_dbg.h"
#include "x_os.h"
#include "x_handle.h"

#define SLIDESHOW_OK				0
#define SLIDESHOW_INVALID_ARG 		-1
#define SLIDESHOW_SEMA_ERROR		-2
#define SLIDESHOW_STOP				-3
#define SLIDESHOW_INITIAL_ERROR		-4
#define SLIDESHOW_MSG_ERROR			-5

#define SLIDESHOW_CLI_INV_ARG		-6
#define SLIDESHOW_CLI_OUT_OF_MEMORY -7

#define PHOTO_SLIDE_SHOW_EFFECT                         1
#define ENABLE_PHOTO_TRANS_EFFECT_BLOCKS                1
#define ENABLE_PHOTO_TRANS_EFFECT_DIAGONAL_BLOCKS       1
#define ENABLE_PHOTO_TRANS_EFFECT_WIPE                  1
#define ENABLE_PHOTO_TRANS_EFFECT_SLIDE                 1
#define ENABLE_PHOTO_TRANS_EFFECT_FADE_IN               1


#if PHOTO_SLIDE_SHOW_EFFECT
/**
 * Slide show effect enum
*/
typedef enum
{
    IMG_SLIDE_SHOW_EFFECT_NORMAL,//0
#if (ENABLE_PHOTO_TRANS_EFFECT_BLOCKS)
    IMG_SLIDE_SHOW_EFFECT_HORZ_BLOCKS_TOPLEFT, //01
    IMG_SLIDE_SHOW_EFFECT_HORZ_BLOCKS_TOPRIGHT,
    IMG_SLIDE_SHOW_EFFECT_HORZ_BLOCKS_BOTTOMLEFT,
    IMG_SLIDE_SHOW_EFFECT_HORZ_BLOCKS_BOTTOMRIGHT,
    IMG_SLIDE_SHOW_EFFECT_VERT_BLOCKS_TOPLEFT,
    IMG_SLIDE_SHOW_EFFECT_VERT_BLOCKS_TOPRIGHT,
    IMG_SLIDE_SHOW_EFFECT_VERT_BLOCKS_BOTTOMLEFT,
    IMG_SLIDE_SHOW_EFFECT_VERT_BLOCKS_BOTTOMRIGHT,
    IMG_SLIDE_SHOW_EFFECT_HORZ_ZIGZAG_BLOCKS_TOPLEFT,
    IMG_SLIDE_SHOW_EFFECT_HORZ_ZIGZAG_BLOCKS_TOPRIGHT,//10
    IMG_SLIDE_SHOW_EFFECT_HORZ_ZIGZAG_BLOCKS_BOTTOMLEFT,
    IMG_SLIDE_SHOW_EFFECT_HORZ_ZIGZAG_BLOCKS_BOTTOMRIGHT,
    IMG_SLIDE_SHOW_EFFECT_VERT_ZIGZAG_BLOCKS_TOPLEFT,
    IMG_SLIDE_SHOW_EFFECT_VERT_ZIGZAG_BLOCKS_TOPRIGHT,
    IMG_SLIDE_SHOW_EFFECT_VERT_ZIGZAG_BLOCKS_BOTTOMLEFT,
    IMG_SLIDE_SHOW_EFFECT_VERT_ZIGZAG_BLOCKS_BOTTOMRIGHT,
    IMG_SLIDE_SHOW_EFFECT_BLOCKS_RANDOM,//17
#endif
#if (ENABLE_PHOTO_TRANS_EFFECT_DIAGONAL_BLOCKS)
    IMG_SLIDE_SHOW_EFFECT_DIAGONAL_BLOCKS_TOPLEFT,
    IMG_SLIDE_SHOW_EFFECT_DIAGONAL_BLOCKS_TOPRIGHT,
    IMG_SLIDE_SHOW_EFFECT_DIAGONAL_BLOCKS_BOTTOMLEFT, //20
    IMG_SLIDE_SHOW_EFFECT_DIAGONAL_BLOCKS_BOTTOMRIGHT,
#endif
#if (ENABLE_PHOTO_TRANS_EFFECT_WIPE)
    IMG_SLIDE_SHOW_EFFECT_BARWIPE_LEFT2RIGHT,//22
    IMG_SLIDE_SHOW_EFFECT_BARWIPE_RIGHT2LEFT,//23
    IMG_SLIDE_SHOW_EFFECT_BARWIPE_TOP2BOTTOM,//24
    IMG_SLIDE_SHOW_EFFECT_BARWIPE_BOTTOM2TOP,//25
    IMG_SLIDE_SHOW_EFFECT_BOXWIPE_TOPLEFT,//26
    IMG_SLIDE_SHOW_EFFECT_BOXWIPE_TOPRIGHT,//27
    IMG_SLIDE_SHOW_EFFECT_BOXWIPE_BOTTOMLEFT,//28
    IMG_SLIDE_SHOW_EFFECT_BOXWIPE_BOTTOMRIGHT,//29
    IMG_SLIDE_SHOW_EFFECT_BARNDOORWIPE_HORIZONTAL_OPEN,//30
    IMG_SLIDE_SHOW_EFFECT_BARNDOORWIPE_HORIZONTAL_CLOSE,//31
    IMG_SLIDE_SHOW_EFFECT_BARNDOORWIPE_VERTICAL_OPEN,//32
    IMG_SLIDE_SHOW_EFFECT_BARNDOORWIPE_VERTICAL_CLOSE,//33
    IMG_SLIDE_SHOW_EFFECT_BOXWIPE_TOPCENTER,//34
    IMG_SLIDE_SHOW_EFFECT_BOXWIPE_RIGHTCENTER,//35
    IMG_SLIDE_SHOW_EFFECT_BOXWIPE_BOTTOMCENTER,//36
    IMG_SLIDE_SHOW_EFFECT_BOXWIPE_LEFTCENTER,//37
    IMG_SLIDE_SHOW_EFFECT_IRISWIPE_CENTER,//38
    IMG_SLIDE_SHOW_EFFECT_IRISWIPE_OUTER,//39
    IMG_SLIDE_SHOW_EFFECT_4BARWIPE_HORIZONTAL_FROM_TOP,//40
    IMG_SLIDE_SHOW_EFFECT_4BARWIPE_HORIZONTAL_FROM_BOTTOM,
    IMG_SLIDE_SHOW_EFFECT_4BARWIPE_VERTICAL_FROM_LEFT,
    IMG_SLIDE_SHOW_EFFECT_4BARWIPE_VERTICAL_FROM_RIGHT,//43
#endif
#if (ENABLE_PHOTO_TRANS_EFFECT_SLIDE)
    IMG_SLIDE_SHOW_EFFECT_BARSLIDE_LEFT2RIGHT,//44
    IMG_SLIDE_SHOW_EFFECT_BARSLIDE_RIGHT2LEFT,
    IMG_SLIDE_SHOW_EFFECT_BARSLIDE_TOP2BOTTOM,
    IMG_SLIDE_SHOW_EFFECT_BARSLIDE_BOTTOM2TOP,
    IMG_SLIDE_SHOW_EFFECT_BOXSLIDE_TOPLEFT,
    IMG_SLIDE_SHOW_EFFECT_BOXSLIDE_TOPRIGHT,
    IMG_SLIDE_SHOW_EFFECT_BOXSLIDE_BOTTOMLEFT,//50
    IMG_SLIDE_SHOW_EFFECT_BOXSLIDE_BOTTOMRIGHT,
    IMG_SLIDE_SHOW_EFFECT_BARNDOORSLIDE_HORIZONTAL_OPEN,
    IMG_SLIDE_SHOW_EFFECT_BARNDOORSLIDE_HORIZONTAL_CLOSE,
    IMG_SLIDE_SHOW_EFFECT_BARNDOORSLIDE_VERTICAL_OPEN,
    IMG_SLIDE_SHOW_EFFECT_BARNDOORSLIDE_VERTICAL_CLOSE,
    IMG_SLIDE_SHOW_EFFECT_4BARSLIDE_HORIZONTAL_FROM_TOP,
    IMG_SLIDE_SHOW_EFFECT_4BARSLIDE_HORIZONTAL_FROM_BOTTOM,
    IMG_SLIDE_SHOW_EFFECT_4BARSLIDE_VERTICAL_FROM_LEFT,
    IMG_SLIDE_SHOW_EFFECT_4BARSLIDE_VERTICAL_FROM_RIGHT,//59
#endif
#if (ENABLE_PHOTO_TRANS_EFFECT_FADE_IN)
    IMG_SLIDE_SHOW_EFFECT_FADE_IN,
#endif
	IMG_SLIDE_SHOW_EFFECT_SLIDE_LEFT2RIGHT,
	IMG_SLIDE_SHOW_EFFECT_SLIDE_RIGHT2LEFT,
    SLIDESHOW_MAX
} IMG_SLIDE_SHOW_EFFECT_T;
#endif //#if PHOTO_SLIDE_SHOW_EFFECT

typedef enum 
{
	SLIDESHOW_NFY_COMPLETE_ONE_FRAME,
	SLIDESHOW_NFY_COMPLETE_ONE_PIC,
	SLIDESHOW_NFY_STOP,
	SLIDESHOW_NFY_PAUSE,
	SLIDESHOW_NFY_RESUME
}SLIDESHOW_NFY_EVENT_TYPE_T;

typedef enum
{
    SLIDESHOW_MSG_START,
    SLIDESHOW_MSG_EXIT
}SLIDESHOW_MSG_TYPE_T;

typedef struct 
{
    SLIDESHOW_MSG_TYPE_T	e_type;
	IMG_SLIDE_SHOW_EFFECT_T 	effect; 
	UCHAR						*src_Y;
	UCHAR						*src_C; //422 YYYY+CbCrCbCr
	UCHAR						*cur_Y;
	UCHAR						*cur_C;
	UCHAR						*dst_Y;
	UCHAR						*dst_C;
	UINT32						ui4_Y_buf_size;
	UINT32						ui4_C_buf_size;
	UINT32						ui4_width;
	UINT32						ui4_height;
	UINT32						ui4_total_time;
}SLIDESHOW_MSG_T;

typedef struct
{
	UCHAR						*puc_src1_Y_addr;
	UCHAR						*puc_src1_C_addr;
	UCHAR						*puc_src2_Y_addr;
	UCHAR						*puc_src2_C_addr;
	UCHAR						*puc_dest_Y_addr;
	UCHAR						*puc_dest_C_addr;
	UINT32						ui4_width;
	UINT32						ui4_height;
	UINT32						ui4_pitch;
	UINT32						ui4_fade_level; //0-127 
}SLIDESHOW_FADE_T;

typedef VOID (*img_slidshow_nfy_fct)	(SLIDESHOW_NFY_EVENT_TYPE_T	e_event	);

typedef VOID (*img_slideshow_nfy_for_fade_fct) (SLIDESHOW_FADE_T  t_fade);
INT32	x_img_init_slideshow(img_slidshow_nfy_fct pf_nfy);
INT32 x_img_slideshow_init_for_fade(img_slideshow_nfy_for_fade_fct pf_nfy);

INT32	x_img_async_slideshow(
	IMG_SLIDE_SHOW_EFFECT_T 	effect, 
	UCHAR						*src_Y,
	UCHAR						*src_C, //422 YYYY+CbCrCbCr
	UCHAR						*cur_Y,
	UCHAR						*cur_C,
	UCHAR						*dst_Y,
	UCHAR						*dst_C,
	UINT32						ui4_Y_buf_size,
	UINT32						ui4_C_buf_size,
	UINT32						ui4_width,
	UINT32						ui4_height,
	UINT32						ui4_total_time);

INT32	x_img_sync_slideshow(
	IMG_SLIDE_SHOW_EFFECT_T 	effect, 
	UCHAR						*src_Y,
	UCHAR						*src_C, //422 YYYY+CbCrCbCr
	UCHAR						*cur_Y,
	UCHAR						*cur_C,
	UCHAR						*dst_Y,
	UCHAR						*dst_C,
	UINT32						ui4_Y_buf_size,
	UINT32						ui4_C_buf_size,
	UINT32						ui4_width,
	UINT32						ui4_height,
	UINT32						ui4_total_time);

INT32	x_img_stop_slideshow(VOID);

#endif

