1 /*****************************************************************************
2  * video_output.h
3  *****************************************************************************
4  * Copyright (C) 2012-2015 L-SMASH Works project
5  *
6  * Authors: Yusuke Nakamura <muken.the.vfrmaniac@gmail.com>
7  *
8  * Permission to use, copy, modify, and/or distribute this software for any
9  * purpose with or without fee is hereby granted, provided that the above
10  * copyright notice and this permission notice appear in all copies.
11  *
12  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19  *****************************************************************************/
20 
21 /* This file is available under an ISC license.
22  * However, when distributing its binary file, it will be under LGPL or GPL. */
23 
24 #include "../common/video_output.h"
25 
26 typedef struct
27 {
28     uint8_t *data    [4];
29     int      linesize[4];
30 } as_picture_t;
31 
32 typedef void func_make_black_background
33 (
34     PVideoFrame &frame,
35     int          bitdepth_minus_8
36 );
37 
38 typedef int func_make_frame
39 (
40     lw_video_output_handler_t *vohp,
41     int                        height,
42     AVFrame                   *av_frame,
43     PVideoFrame               &as_frame
44 );
45 
46 typedef struct
47 {
48     func_make_black_background *make_black_background;
49     func_make_frame            *make_frame;
50     IScriptEnvironment         *env;
51     VideoInfo                  *vi;
52     int                         bitdepth_minus_8;
53     /* for stacked format */
54     int                         stacked_format;
55     int                         sub_width;
56     int                         sub_height;
57     as_picture_t                scaled;
58 } as_video_output_handler_t;
59 
60 typedef struct
61 {
62     PVideoFrame as_frame_buffer;
63 } as_video_buffer_handler_t;
64 
65 enum AVPixelFormat get_av_output_pixel_format
66 (
67     const char *format_name
68 );
69 
70 int make_frame
71 (
72     lw_video_output_handler_t *vohp,
73     AVFrame                   *av_frame,
74     PVideoFrame               &as_frame,
75     IScriptEnvironment        *env
76 );
77 
78 void as_free_video_output_handler
79 (
80     void *private_handler
81 );
82 
83 void as_setup_video_rendering
84 (
85     lw_video_output_handler_t *vohp,
86     AVCodecContext            *ctx,
87     const char                *filter_name,
88     int                        direct_rendering,
89     int                        stacked_format,
90     enum AVPixelFormat         output_pixel_format,
91     int                        output_width,
92     int                        output_height
93 );
94