1 /*****************************************************************************
2 * source.c: source video filter
3 *****************************************************************************
4 * Copyright (C) 2010-2016 x264 project
6 * Authors: Steven Walters <kemuri9@gmail.com>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA.
22 * This program is also available under a commercial proprietary license.
23 * For more information, contact us at licensing@x264.com.
24 *****************************************************************************/
28 /* This filter converts the demuxer API into the filtering API for video frames.
29 * Backseeking is prohibited here as not all demuxers are capable of doing so. */
38 cli_vid_filter_t source_filter;
40 static int init( hnd_t *handle, cli_vid_filter_t *filter, video_info_t *info, x264_param_t *param, char *opt_string )
42 source_hnd_t *h = calloc( 1, sizeof(source_hnd_t) );
47 if( cli_input.picture_alloc( &h->pic, *handle, info->csp, info->width, info->height ) )
52 *filter = source_filter;
57 static int get_frame( hnd_t handle, cli_pic_t *output, int frame )
59 source_hnd_t *h = handle;
60 /* do not allow requesting of frames from before the current position */
61 if( frame <= h->cur_frame || cli_input.read_frame( &h->pic, h->hin, frame ) )
68 static int release_frame( hnd_t handle, cli_pic_t *pic, int frame )
70 source_hnd_t *h = handle;
71 if( cli_input.release_frame && cli_input.release_frame( &h->pic, h->hin ) )
76 static void free_filter( hnd_t handle )
78 source_hnd_t *h = handle;
79 cli_input.picture_clean( &h->pic, h->hin );
80 cli_input.close_file( h->hin );
84 cli_vid_filter_t source_filter = { "source", NULL, init, get_frame, release_frame, free_filter, NULL };