* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
+#define _LARGEFILE_SOURCE
+#define _FILE_OFFSET_BITS 64
+
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <fcntl.h> /* _O_BINARY */
#endif
+#ifndef _MSC_VER
+#include "config.h"
+#endif
+
#ifdef AVIS_INPUT
#include <windows.h>
#include <vfw.h>
#include "common/common.h"
#include "x264.h"
-#ifndef _MSC_VER
-#include "config.h"
-#endif
-
#include "matroska.h"
#define DATA_MAX 3000000
" --merange <integer> Maximum motion vector search range [%d]\n"
" -m, --subme <integer> Subpixel motion estimation and partition\n"
" decision quality: 1=fast, 6=best. [%d]\n"
+ " --b-rdo RD based mode decision for B-frames. Requires subme 6.\n"
" --mixed-refs Decide references on a per partition basis\n"
" --no-chroma-me Ignore chroma in motion estimation\n"
+ " --bime Jointly optimize both MVs in B-frames\n"
" -8, --8x8dct Adaptive spatial transform size\n"
+ " -t, --trellis <integer> Trellis RD quantization. Requires CABAC. [%d]\n"
+ " - 0: disabled\n"
+ " - 1: enabled only on the final encode of a MB\n"
+ " - 2: enabled on all mode decisions\n"
+ " --no-fast-pskip Disables early SKIP detection on P-frames\n"
+ " --nr <integer> Noise reduction [%d]\n"
"\n"
" --cqm <string> Preset quant matrices [\"flat\"]\n"
" - jvt, flat\n"
"\n"
"Input/Output:\n"
"\n"
- " --level <integer> Specify level (as defined by Annex A)\n"
+ " --level <string> Specify level (as defined by Annex A)\n"
" --fps <float|rational> Specify framerate\n"
" --seek <integer> First frame to encode\n"
" --frames <integer> Maximum number of frames to encode\n"
strtable_lookup( x264_motion_est_names, defaults->analyse.i_me_method ),
defaults->analyse.i_me_range,
defaults->analyse.i_subpel_refine,
+ defaults->analyse.i_trellis,
+ defaults->analyse.i_noise_reduction,
strtable_lookup( overscan_str, defaults->vui.i_overscan ),
strtable_lookup( vidformat_str, defaults->vui.i_vidformat ),
strtable_lookup( fullrange_str, defaults->vui.b_fullrange ),
#define OPT_CHROMALOC 313
#define OPT_MIXED_REFS 314
#define OPT_CRF 315
+#define OPT_B_RDO 316
+#define OPT_NO_FAST_PSKIP 317
+#define OPT_BIME 318
+#define OPT_NR 319
static struct option long_options[] =
{
{ "me", required_argument, NULL, OPT_ME },
{ "merange", required_argument, NULL, OPT_MERANGE },
{ "subme", required_argument, NULL, 'm' },
+ { "b-rdo", no_argument, NULL, OPT_B_RDO },
{ "mixed-refs", no_argument, NULL, OPT_MIXED_REFS },
{ "no-chroma-me", no_argument, NULL, OPT_NO_CHROMA_ME },
+ { "bime", no_argument, NULL, OPT_BIME },
{ "8x8dct", no_argument, NULL, '8' },
+ { "trellis", required_argument, NULL, 't' },
+ { "no-fast-pskip", no_argument, NULL, OPT_NO_FAST_PSKIP },
{ "level", required_argument, NULL, OPT_LEVEL },
{ "ratetol", required_argument, NULL, OPT_RATETOL },
{ "vbv-maxrate", required_argument, NULL, OPT_VBVMAXRATE },
{ "progress",no_argument, NULL, OPT_PROGRESS },
{ "visualize",no_argument, NULL, OPT_VISUALIZE },
{ "aud", no_argument, NULL, OPT_AUD },
+ { "nr", required_argument, NULL, OPT_NR },
{ "cqm", required_argument, NULL, OPT_CQM },
{ "cqmfile", required_argument, NULL, OPT_CQMFILE },
{ "cqm4", required_argument, NULL, OPT_CQM4 },
int c;
- c = getopt_long( argc, argv, "hi:I:b:r:cxB:q:f:o:A:m:p:vw8",
+ c = getopt_long( argc, argv, "hi:I:b:r:cxB:q:f:o:A:m:p:t:vw8",
long_options, &long_options_index);
if( c == -1 )
case 'f':
{
char *p = strchr( optarg, ':' );
+ if( !p ) p = strchr( optarg, ',' );
param->i_deblocking_filter_alphac0 = atoi( optarg );
param->i_deblocking_filter_beta = p ? atoi( p+1 ) : param->i_deblocking_filter_alphac0;
break;
case OPT_SAR:
{
char *p = strchr( optarg, ':' );
+ if( !p ) p = strchr( optarg, '/' );
if( p )
{
param->vui.i_sar_width = atoi( optarg );
case 'm':
param->analyse.i_subpel_refine = atoi(optarg);
break;
+ case OPT_B_RDO:
+ param->analyse.b_bframe_rdo = 1;
+ break;
case OPT_MIXED_REFS:
param->analyse.b_mixed_references = 1;
break;
case OPT_NO_CHROMA_ME:
param->analyse.b_chroma_me = 0;
break;
+ case OPT_BIME:
+ param->analyse.b_bidir_me = 1;
+ break;
case '8':
param->analyse.b_transform_8x8 = 1;
break;
+ case 't':
+ param->analyse.i_trellis = atoi(optarg);
+ break;
+ case OPT_NO_FAST_PSKIP:
+ param->analyse.b_fast_pskip = 0;
+ break;
case OPT_LEVEL:
- param->i_level_idc = atoi(optarg);
+ if( atof(optarg) < 6 )
+ param->i_level_idc = (int)(10*atof(optarg)+.5);
+ else
+ param->i_level_idc = atoi(optarg);
break;
case OPT_RATETOL:
param->rc.f_rate_tolerance = !strncmp("inf", optarg, 3) ? 1e9 : atof(optarg);
fprintf( stderr, "not compiled with visualization support\n" );
#endif
break;
+ case OPT_NR:
+ param->analyse.i_noise_reduction = atoi(optarg);
+ break;
case OPT_CQM:
if( strstr( optarg, "flat" ) )
param->i_cqm_preset = X264_CQM_FLAT;
break;
case OPT_CQM4PY:
param->i_cqm_preset = X264_CQM_CUSTOM;
- b_error |= parse_cqm( optarg, param->cqm_4iy, 16 );
+ b_error |= parse_cqm( optarg, param->cqm_4py, 16 );
break;
case OPT_CQM4PC:
param->i_cqm_preset = X264_CQM_CUSTOM;
- b_error |= parse_cqm( optarg, param->cqm_4ic, 16 );
+ b_error |= parse_cqm( optarg, param->cqm_4pc, 16 );
break;
case OPT_CQM8I:
param->i_cqm_preset = X264_CQM_CUSTOM;
if( !fseek( f, 0, SEEK_END ) )
{
- int64_t i_size = ftell( f );
+ uint64_t i_size = ftell( f );
fseek( f, 0, SEEK_SET );
i_frame_total = (int)(i_size / ( i_width * i_height * 3 / 2 ));
}
FILE *f = (FILE *)handle;
if( i_frame != prev_frame+1 )
- if( fseek( f, i_frame * i_width * i_height * 3 / 2, SEEK_SET ) )
+ if( fseek( f, (uint64_t)i_frame * i_width * i_height * 3 / 2, SEEK_SET ) )
return -1;
if( fread( p_pic->img.plane[0], 1, i_width * i_height, f ) <= 0
gf_isom_avc_config_new(p_mp4->p_file, p_mp4->i_track, p_mp4->p_config,
NULL, NULL, &p_mp4->i_descidx);
+ gf_isom_set_track_enabled(p_mp4->p_file, p_mp4->i_track, 1);
+
gf_isom_set_visual_info(p_mp4->p_file, p_mp4->i_track, p_mp4->i_descidx,
p_param->i_width, p_param->i_height);
static int set_eop_mp4( hnd_t handle, x264_picture_t *p_picture )
{
mp4_t *p_mp4 = (mp4_t *)handle;
- uint32_t dts = p_mp4->i_numframe * p_mp4->i_time_inc;
- uint32_t pts = p_picture->i_pts;
- int offset = p_mp4->i_init_delay + pts - dts;
+ uint64_t dts = (uint64_t)p_mp4->i_numframe * p_mp4->i_time_inc;
+ uint64_t pts = (uint64_t)p_picture->i_pts;
+ int32_t offset = p_mp4->i_init_delay + pts - dts;
p_mp4->p_sample->IsRAP = p_picture->i_type == X264_TYPE_IDR ? 1 : 0;
p_mp4->p_sample->DTS = dts;
avcC[1] = p_mkv->sps[1];
avcC[2] = p_mkv->sps[2];
avcC[3] = p_mkv->sps[3];
- avcC[4] = 0xfe; // nalu size length is three bytes
+ avcC[4] = 0xff; // nalu size length is four bytes
avcC[5] = 0xe1; // one sps
avcC[6] = p_mkv->sps_len >> 8;
{
mkv_t *p_mkv = handle;
uint8_t type = p_nalu[4] & 0x1f;
- uint8_t dsize[3];
+ uint8_t dsize[4];
int psize;
switch( type )
p_mkv->b_writing_frame = 1;
}
psize = i_size - 4 ;
- dsize[0] = psize >> 16;
- dsize[1] = psize >> 8;
- dsize[2] = psize;
- if( mk_addFrameData(p_mkv->w, dsize, 3) < 0 ||
+ dsize[0] = psize >> 24;
+ dsize[1] = psize >> 16;
+ dsize[2] = psize >> 8;
+ dsize[3] = psize;
+ if( mk_addFrameData(p_mkv->w, dsize, 4) < 0 ||
mk_addFrameData(p_mkv->w, p_nalu + 4, i_size - 4) < 0 )
return -1;
break;