2005-07-22 17:51:10 +02:00
|
|
|
/*****************************************************************************
|
2010-09-17 13:03:27 +02:00
|
|
|
* input.h: file input
|
2005-07-22 17:51:10 +02:00
|
|
|
*****************************************************************************
|
2020-02-29 20:02:01 +01:00
|
|
|
* Copyright (C) 2003-2020 x264 project
|
2009-10-24 02:23:50 +02:00
|
|
|
*
|
|
|
|
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
|
|
|
|
* Loren Merritt <lorenm@u.washington.edu>
|
LAVF/FFMS input support, native VFR timestamp handling
libx264 now takes three new API parameters.
b_vfr_input tells x264 whether or not the input is VFR, and is 1 by default.
i_timebase_num and i_timebase_den pass the timebase to x264.
x264_picture_t now returns the DTS of each frame: the calling app need not calculate it anymore.
Add libavformat and FFMS2 input support: requires libav* and ffms2 libraries respectively.
FFMS2 is _STRONGLY_ preferred over libavformat: we encourage all distributions to compile with FFMS2 support if at all possible.
FFMS2 can be found at http://code.google.com/p/ffmpegsource/.
--index, a new x264cli option, allows the user to store (or load) an FFMS2 index file for future use, to avoid re-indexing in the future.
Overhaul the muxers to pass through timestamps instead of assuming CFR.
Also overhaul muxers to correctly use b_annexb and b_repeat_headers to simplify the code.
Remove VFW input support, since it's now pretty much redundant with native AVS support and LAVF support.
Finally, overhaul a large part of the x264cli internals.
--force-cfr, a new x264cli option, allows the user to force the old method of timestamp handling. May be useful in case of a source with broken timestamps.
Avisynth, YUV, and Y4M input are all still CFR. LAVF or FFMS2 must be used for VFR support.
Do note that this patch does *not* add VFR ratecontrol yet.
Support for telecined input is also somewhat dubious at the moment.
Large parts of this patch by Mike Gurlitz <mike.gurlitz@gmail.com>, Steven Walters <kemuri9@gmail.com>, and Yusuke Nakamura <muken.the.vfrmaniac@gmail.com>.
2009-12-28 16:42:17 +01:00
|
|
|
* Steven Walters <kemuri9@gmail.com>
|
2005-07-22 17:51:10 +02:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* 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 the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2008-07-04 04:05:00 +02:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA.
|
2010-09-17 13:03:27 +02:00
|
|
|
*
|
|
|
|
* This program is also available under a commercial proprietary license.
|
|
|
|
* For more information, contact us at licensing@x264.com.
|
2005-07-22 17:51:10 +02:00
|
|
|
*****************************************************************************/
|
|
|
|
|
2009-10-24 02:23:50 +02:00
|
|
|
#ifndef X264_INPUT_H
|
|
|
|
#define X264_INPUT_H
|
2005-07-22 17:51:10 +02:00
|
|
|
|
2010-06-26 22:28:49 +02:00
|
|
|
#include "x264cli.h"
|
|
|
|
|
2016-07-28 21:58:40 +02:00
|
|
|
#ifdef _WIN32
|
|
|
|
#include <windows.h>
|
|
|
|
#endif
|
|
|
|
|
LAVF/FFMS input support, native VFR timestamp handling
libx264 now takes three new API parameters.
b_vfr_input tells x264 whether or not the input is VFR, and is 1 by default.
i_timebase_num and i_timebase_den pass the timebase to x264.
x264_picture_t now returns the DTS of each frame: the calling app need not calculate it anymore.
Add libavformat and FFMS2 input support: requires libav* and ffms2 libraries respectively.
FFMS2 is _STRONGLY_ preferred over libavformat: we encourage all distributions to compile with FFMS2 support if at all possible.
FFMS2 can be found at http://code.google.com/p/ffmpegsource/.
--index, a new x264cli option, allows the user to store (or load) an FFMS2 index file for future use, to avoid re-indexing in the future.
Overhaul the muxers to pass through timestamps instead of assuming CFR.
Also overhaul muxers to correctly use b_annexb and b_repeat_headers to simplify the code.
Remove VFW input support, since it's now pretty much redundant with native AVS support and LAVF support.
Finally, overhaul a large part of the x264cli internals.
--force-cfr, a new x264cli option, allows the user to force the old method of timestamp handling. May be useful in case of a source with broken timestamps.
Avisynth, YUV, and Y4M input are all still CFR. LAVF or FFMS2 must be used for VFR support.
Do note that this patch does *not* add VFR ratecontrol yet.
Support for telecined input is also somewhat dubious at the moment.
Large parts of this patch by Mike Gurlitz <mike.gurlitz@gmail.com>, Steven Walters <kemuri9@gmail.com>, and Yusuke Nakamura <muken.the.vfrmaniac@gmail.com>.
2009-12-28 16:42:17 +01:00
|
|
|
/* options that are used by only some demuxers */
|
2009-10-24 02:23:50 +02:00
|
|
|
typedef struct
|
|
|
|
{
|
2010-06-08 00:43:37 +02:00
|
|
|
char *index_file;
|
2011-01-20 15:12:01 +01:00
|
|
|
char *format;
|
2010-07-05 23:37:47 +02:00
|
|
|
char *resolution;
|
|
|
|
char *colorspace;
|
2010-09-27 16:02:20 +02:00
|
|
|
int bit_depth;
|
2010-03-01 06:42:19 +01:00
|
|
|
char *timebase;
|
LAVF/FFMS input support, native VFR timestamp handling
libx264 now takes three new API parameters.
b_vfr_input tells x264 whether or not the input is VFR, and is 1 by default.
i_timebase_num and i_timebase_den pass the timebase to x264.
x264_picture_t now returns the DTS of each frame: the calling app need not calculate it anymore.
Add libavformat and FFMS2 input support: requires libav* and ffms2 libraries respectively.
FFMS2 is _STRONGLY_ preferred over libavformat: we encourage all distributions to compile with FFMS2 support if at all possible.
FFMS2 can be found at http://code.google.com/p/ffmpegsource/.
--index, a new x264cli option, allows the user to store (or load) an FFMS2 index file for future use, to avoid re-indexing in the future.
Overhaul the muxers to pass through timestamps instead of assuming CFR.
Also overhaul muxers to correctly use b_annexb and b_repeat_headers to simplify the code.
Remove VFW input support, since it's now pretty much redundant with native AVS support and LAVF support.
Finally, overhaul a large part of the x264cli internals.
--force-cfr, a new x264cli option, allows the user to force the old method of timestamp handling. May be useful in case of a source with broken timestamps.
Avisynth, YUV, and Y4M input are all still CFR. LAVF or FFMS2 must be used for VFR support.
Do note that this patch does *not* add VFR ratecontrol yet.
Support for telecined input is also somewhat dubious at the moment.
Large parts of this patch by Mike Gurlitz <mike.gurlitz@gmail.com>, Steven Walters <kemuri9@gmail.com>, and Yusuke Nakamura <muken.the.vfrmaniac@gmail.com>.
2009-12-28 16:42:17 +01:00
|
|
|
int seek;
|
2011-04-05 12:06:54 +02:00
|
|
|
int progress;
|
2011-06-22 12:32:53 +02:00
|
|
|
int output_csp; /* convert to this csp, if applicable */
|
2011-11-06 18:48:30 +01:00
|
|
|
int output_range; /* user desired output range */
|
|
|
|
int input_range; /* user override input range */
|
LAVF/FFMS input support, native VFR timestamp handling
libx264 now takes three new API parameters.
b_vfr_input tells x264 whether or not the input is VFR, and is 1 by default.
i_timebase_num and i_timebase_den pass the timebase to x264.
x264_picture_t now returns the DTS of each frame: the calling app need not calculate it anymore.
Add libavformat and FFMS2 input support: requires libav* and ffms2 libraries respectively.
FFMS2 is _STRONGLY_ preferred over libavformat: we encourage all distributions to compile with FFMS2 support if at all possible.
FFMS2 can be found at http://code.google.com/p/ffmpegsource/.
--index, a new x264cli option, allows the user to store (or load) an FFMS2 index file for future use, to avoid re-indexing in the future.
Overhaul the muxers to pass through timestamps instead of assuming CFR.
Also overhaul muxers to correctly use b_annexb and b_repeat_headers to simplify the code.
Remove VFW input support, since it's now pretty much redundant with native AVS support and LAVF support.
Finally, overhaul a large part of the x264cli internals.
--force-cfr, a new x264cli option, allows the user to force the old method of timestamp handling. May be useful in case of a source with broken timestamps.
Avisynth, YUV, and Y4M input are all still CFR. LAVF or FFMS2 must be used for VFR support.
Do note that this patch does *not* add VFR ratecontrol yet.
Support for telecined input is also somewhat dubious at the moment.
Large parts of this patch by Mike Gurlitz <mike.gurlitz@gmail.com>, Steven Walters <kemuri9@gmail.com>, and Yusuke Nakamura <muken.the.vfrmaniac@gmail.com>.
2009-12-28 16:42:17 +01:00
|
|
|
} cli_input_opt_t;
|
|
|
|
|
|
|
|
/* properties of the source given by the demuxer */
|
|
|
|
typedef struct
|
|
|
|
{
|
2010-07-05 23:37:47 +02:00
|
|
|
int csp; /* colorspace of the input */
|
2010-04-16 20:36:43 +02:00
|
|
|
uint32_t fps_num;
|
|
|
|
uint32_t fps_den;
|
2011-11-06 18:48:30 +01:00
|
|
|
int fullrange; /* has 2^bit_depth-1 instead of 219*2^(bit_depth-8) ranges (YUV only) */
|
|
|
|
int width;
|
LAVF/FFMS input support, native VFR timestamp handling
libx264 now takes three new API parameters.
b_vfr_input tells x264 whether or not the input is VFR, and is 1 by default.
i_timebase_num and i_timebase_den pass the timebase to x264.
x264_picture_t now returns the DTS of each frame: the calling app need not calculate it anymore.
Add libavformat and FFMS2 input support: requires libav* and ffms2 libraries respectively.
FFMS2 is _STRONGLY_ preferred over libavformat: we encourage all distributions to compile with FFMS2 support if at all possible.
FFMS2 can be found at http://code.google.com/p/ffmpegsource/.
--index, a new x264cli option, allows the user to store (or load) an FFMS2 index file for future use, to avoid re-indexing in the future.
Overhaul the muxers to pass through timestamps instead of assuming CFR.
Also overhaul muxers to correctly use b_annexb and b_repeat_headers to simplify the code.
Remove VFW input support, since it's now pretty much redundant with native AVS support and LAVF support.
Finally, overhaul a large part of the x264cli internals.
--force-cfr, a new x264cli option, allows the user to force the old method of timestamp handling. May be useful in case of a source with broken timestamps.
Avisynth, YUV, and Y4M input are all still CFR. LAVF or FFMS2 must be used for VFR support.
Do note that this patch does *not* add VFR ratecontrol yet.
Support for telecined input is also somewhat dubious at the moment.
Large parts of this patch by Mike Gurlitz <mike.gurlitz@gmail.com>, Steven Walters <kemuri9@gmail.com>, and Yusuke Nakamura <muken.the.vfrmaniac@gmail.com>.
2009-12-28 16:42:17 +01:00
|
|
|
int height;
|
|
|
|
int interlaced;
|
2010-07-05 23:37:47 +02:00
|
|
|
int num_frames;
|
2010-04-16 20:36:43 +02:00
|
|
|
uint32_t sar_width;
|
|
|
|
uint32_t sar_height;
|
2010-04-07 04:08:21 +02:00
|
|
|
int tff;
|
2010-07-05 23:37:47 +02:00
|
|
|
int thread_safe; /* demuxer is thread_input safe */
|
2010-04-16 20:36:43 +02:00
|
|
|
uint32_t timebase_num;
|
|
|
|
uint32_t timebase_den;
|
LAVF/FFMS input support, native VFR timestamp handling
libx264 now takes three new API parameters.
b_vfr_input tells x264 whether or not the input is VFR, and is 1 by default.
i_timebase_num and i_timebase_den pass the timebase to x264.
x264_picture_t now returns the DTS of each frame: the calling app need not calculate it anymore.
Add libavformat and FFMS2 input support: requires libav* and ffms2 libraries respectively.
FFMS2 is _STRONGLY_ preferred over libavformat: we encourage all distributions to compile with FFMS2 support if at all possible.
FFMS2 can be found at http://code.google.com/p/ffmpegsource/.
--index, a new x264cli option, allows the user to store (or load) an FFMS2 index file for future use, to avoid re-indexing in the future.
Overhaul the muxers to pass through timestamps instead of assuming CFR.
Also overhaul muxers to correctly use b_annexb and b_repeat_headers to simplify the code.
Remove VFW input support, since it's now pretty much redundant with native AVS support and LAVF support.
Finally, overhaul a large part of the x264cli internals.
--force-cfr, a new x264cli option, allows the user to force the old method of timestamp handling. May be useful in case of a source with broken timestamps.
Avisynth, YUV, and Y4M input are all still CFR. LAVF or FFMS2 must be used for VFR support.
Do note that this patch does *not* add VFR ratecontrol yet.
Support for telecined input is also somewhat dubious at the moment.
Large parts of this patch by Mike Gurlitz <mike.gurlitz@gmail.com>, Steven Walters <kemuri9@gmail.com>, and Yusuke Nakamura <muken.the.vfrmaniac@gmail.com>.
2009-12-28 16:42:17 +01:00
|
|
|
int vfr;
|
|
|
|
} video_info_t;
|
|
|
|
|
2010-07-05 23:37:47 +02:00
|
|
|
/* image data type used by x264cli */
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int csp; /* colorspace */
|
|
|
|
int width; /* width of the picture */
|
|
|
|
int height; /* height of the picture */
|
|
|
|
int planes; /* number of planes */
|
|
|
|
uint8_t *plane[4]; /* pointers for each plane */
|
|
|
|
int stride[4]; /* strides for each plane */
|
|
|
|
} cli_image_t;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
cli_image_t img;
|
|
|
|
int64_t pts; /* input pts */
|
|
|
|
int64_t duration; /* frame duration - used for vfr */
|
|
|
|
void *opaque; /* opaque handle */
|
|
|
|
} cli_pic_t;
|
|
|
|
|
LAVF/FFMS input support, native VFR timestamp handling
libx264 now takes three new API parameters.
b_vfr_input tells x264 whether or not the input is VFR, and is 1 by default.
i_timebase_num and i_timebase_den pass the timebase to x264.
x264_picture_t now returns the DTS of each frame: the calling app need not calculate it anymore.
Add libavformat and FFMS2 input support: requires libav* and ffms2 libraries respectively.
FFMS2 is _STRONGLY_ preferred over libavformat: we encourage all distributions to compile with FFMS2 support if at all possible.
FFMS2 can be found at http://code.google.com/p/ffmpegsource/.
--index, a new x264cli option, allows the user to store (or load) an FFMS2 index file for future use, to avoid re-indexing in the future.
Overhaul the muxers to pass through timestamps instead of assuming CFR.
Also overhaul muxers to correctly use b_annexb and b_repeat_headers to simplify the code.
Remove VFW input support, since it's now pretty much redundant with native AVS support and LAVF support.
Finally, overhaul a large part of the x264cli internals.
--force-cfr, a new x264cli option, allows the user to force the old method of timestamp handling. May be useful in case of a source with broken timestamps.
Avisynth, YUV, and Y4M input are all still CFR. LAVF or FFMS2 must be used for VFR support.
Do note that this patch does *not* add VFR ratecontrol yet.
Support for telecined input is also somewhat dubious at the moment.
Large parts of this patch by Mike Gurlitz <mike.gurlitz@gmail.com>, Steven Walters <kemuri9@gmail.com>, and Yusuke Nakamura <muken.the.vfrmaniac@gmail.com>.
2009-12-28 16:42:17 +01:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int (*open_file)( char *psz_filename, hnd_t *p_handle, video_info_t *info, cli_input_opt_t *opt );
|
2015-10-26 19:54:20 +01:00
|
|
|
int (*picture_alloc)( cli_pic_t *pic, hnd_t handle, int csp, int width, int height );
|
2010-07-05 23:37:47 +02:00
|
|
|
int (*read_frame)( cli_pic_t *pic, hnd_t handle, int i_frame );
|
|
|
|
int (*release_frame)( cli_pic_t *pic, hnd_t handle );
|
2015-10-26 19:54:20 +01:00
|
|
|
void (*picture_clean)( cli_pic_t *pic, hnd_t handle );
|
2009-10-24 02:23:50 +02:00
|
|
|
int (*close_file)( hnd_t handle );
|
|
|
|
} cli_input_t;
|
2005-07-22 17:51:10 +02:00
|
|
|
|
2010-07-05 23:37:47 +02:00
|
|
|
extern const cli_input_t raw_input;
|
2010-02-13 08:22:04 +01:00
|
|
|
extern const cli_input_t y4m_input;
|
|
|
|
extern const cli_input_t avs_input;
|
Unify 8-bit and 10-bit CLI and libraries
Add 'i_bitdepth' to x264_param_t with the corresponding '--output-depth' CLI
option to set the bit depth at runtime.
Drop the 'x264_bit_depth' global variable. Rather than hardcoding it to an
incorrect value, it's preferable to induce a linking failure. If applications
relies on this symbol this will make it more obvious where the problem is.
Add Makefile rules that compiles modules with different bit depths. Assembly
on x86 is prefixed with the 'private_prefix' define, while all other archs
modify their function prefix internally.
Templatize the main C library, x86/x86_64 assembly, ARM assembly, AARCH64
assembly, PowerPC assembly, and MIPS assembly.
The depth and cache CLI filters heavily depend on bit depth size, so they
need to be duplicated for each value. This means having to rename these
filters, and adjust the callers to use the right version.
Unfortunately the threaded input CLI module inherits a common.h dependency
(input/frame -> common/threadpool -> common/frame -> common/common) which
is extremely complicated to address in a sensible way. Instead duplicate
the module and select the appropriate one at run time.
Each bitdepth needs different checkasm compilation rules, so split the main
checkasm target into two executables.
2017-01-06 15:23:38 +01:00
|
|
|
extern const cli_input_t thread_8_input;
|
|
|
|
extern const cli_input_t thread_10_input;
|
2010-02-13 08:22:04 +01:00
|
|
|
extern const cli_input_t lavf_input;
|
|
|
|
extern const cli_input_t ffms_input;
|
2015-10-26 19:54:20 +01:00
|
|
|
extern const cli_input_t timecode_input;
|
2005-07-22 17:51:10 +02:00
|
|
|
|
2011-07-20 16:06:41 +02:00
|
|
|
extern cli_input_t cli_input;
|
2010-07-05 23:37:47 +02:00
|
|
|
|
|
|
|
/* extended colorspace list that isn't supported by libx264 but by the cli */
|
2011-08-26 15:57:04 +02:00
|
|
|
#define X264_CSP_CLI_MAX X264_CSP_MAX /* end of list */
|
2010-09-27 16:02:20 +02:00
|
|
|
#define X264_CSP_OTHER 0x4000 /* non x264 colorspace */
|
2010-07-05 23:37:47 +02:00
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
const char *name;
|
|
|
|
int planes;
|
|
|
|
float width[4];
|
|
|
|
float height[4];
|
|
|
|
int mod_width;
|
|
|
|
int mod_height;
|
|
|
|
} x264_cli_csp_t;
|
|
|
|
|
|
|
|
extern const x264_cli_csp_t x264_cli_csps[];
|
|
|
|
|
|
|
|
int x264_cli_csp_is_invalid( int csp );
|
2010-09-27 16:02:20 +02:00
|
|
|
int x264_cli_csp_depth_factor( int csp );
|
2010-07-05 23:37:47 +02:00
|
|
|
int x264_cli_pic_alloc( cli_pic_t *pic, int csp, int width, int height );
|
2013-10-08 21:32:37 +02:00
|
|
|
int x264_cli_pic_alloc_aligned( cli_pic_t *pic, int csp, int width, int height );
|
2015-10-26 19:54:20 +01:00
|
|
|
int x264_cli_pic_init_noalloc( cli_pic_t *pic, int csp, int width, int height );
|
2010-07-05 23:37:47 +02:00
|
|
|
void x264_cli_pic_clean( cli_pic_t *pic );
|
2019-11-15 01:04:16 +01:00
|
|
|
int64_t x264_cli_pic_plane_size( int csp, int width, int height, int plane );
|
|
|
|
int64_t x264_cli_pic_size( int csp, int width, int height );
|
2010-07-05 23:37:47 +02:00
|
|
|
const x264_cli_csp_t *x264_cli_get_csp( int csp );
|
|
|
|
|
2015-10-26 19:54:20 +01:00
|
|
|
typedef struct
|
|
|
|
{
|
2017-10-22 09:59:28 +02:00
|
|
|
int64_t file_size;
|
2015-10-26 19:54:20 +01:00
|
|
|
int align_mask;
|
|
|
|
#ifdef _WIN32
|
2017-10-22 09:59:28 +02:00
|
|
|
int page_mask;
|
2016-07-28 21:58:40 +02:00
|
|
|
BOOL (WINAPI *prefetch_virtual_memory)( HANDLE, ULONG_PTR, PVOID, ULONG );
|
|
|
|
HANDLE process_handle;
|
|
|
|
HANDLE map_handle;
|
2015-10-26 19:54:20 +01:00
|
|
|
#elif HAVE_MMAP
|
|
|
|
int fd;
|
|
|
|
#endif
|
|
|
|
} cli_mmap_t;
|
|
|
|
|
|
|
|
int x264_cli_mmap_init( cli_mmap_t *h, FILE *fh );
|
2019-11-15 01:04:16 +01:00
|
|
|
void *x264_cli_mmap( cli_mmap_t *h, int64_t offset, int64_t size );
|
|
|
|
int x264_cli_munmap( cli_mmap_t *h, void *addr, int64_t size );
|
2015-10-26 19:54:20 +01:00
|
|
|
void x264_cli_mmap_close( cli_mmap_t *h );
|
|
|
|
|
2005-07-22 17:51:10 +02:00
|
|
|
#endif
|