* qatar/master: avconv: Replace goto redo on decode fail with continue. avconv: Remove dead store. libx264: add 'crf_max' private option. libx264: add 'weightp' private option. libx264: add 'rc_lookahead' private option. libx264: add 'psy_trellis' private option. libx264: add 'psy_rd' private option. libx264: add 'aq_strength' private option. libx264: add 'aq_mode' private option. libx264: add 'cqp' private option. libx264: add 'crf' private option. lavc: remove vbv_delay option lavf utils: Fix bad indentation. avconv: use av_clip_int16 for audio clipping Conflicts: libavcodec/libx264.c libavcodec/options.c Merged-by: Michael Niedermayer <michaelni@gmx.at>tags/n0.9
| @@ -1687,7 +1687,6 @@ static int output_packet(InputStream *ist, int ist_index, | |||
| } | |||
| break; | |||
| } | |||
| ret = avpkt.size; | |||
| avpkt.size = 0; | |||
| } | |||
| @@ -1698,9 +1697,7 @@ static int output_packet(InputStream *ist, int ist_index, | |||
| volp = samples; | |||
| for(i=0;i<(decoded_data_size / sizeof(short));i++) { | |||
| int v = ((*volp) * audio_volume + 128) >> 8; | |||
| if (v < -32768) v = -32768; | |||
| if (v > 32767) v = 32767; | |||
| *volp++ = v; | |||
| *volp++ = av_clip_int16(v); | |||
| } | |||
| } | |||
| } | |||
| @@ -2307,7 +2304,6 @@ static int transcode(OutputFile *output_files, | |||
| int64_t ipts_min; | |||
| double opts_min; | |||
| redo: | |||
| ipts_min = INT64_MAX; | |||
| opts_min= 1e100; | |||
| /* if 'q' pressed, exits */ | |||
| @@ -2473,7 +2469,7 @@ static int transcode(OutputFile *output_files, | |||
| if (exit_on_error) | |||
| exit_program(1); | |||
| av_free_packet(&pkt); | |||
| goto redo; | |||
| continue; | |||
| } | |||
| discard_packet: | |||
| @@ -2425,19 +2425,23 @@ typedef struct AVCodecContext { | |||
| */ | |||
| int brd_scale; | |||
| #if FF_API_X264_GLOBAL_OPTS | |||
| /** | |||
| * constant rate factor - quality-based VBR - values ~correspond to qps | |||
| * - encoding: Set by user. | |||
| * - decoding: unused | |||
| * @deprecated use 'crf' libx264 private option | |||
| */ | |||
| float crf; | |||
| attribute_deprecated float crf; | |||
| /** | |||
| * constant quantization parameter rate control method | |||
| * - encoding: Set by user. | |||
| * - decoding: unused | |||
| * @deprecated use 'cqp' libx264 private option | |||
| */ | |||
| int cqp; | |||
| attribute_deprecated int cqp; | |||
| #endif | |||
| /** | |||
| * minimum GOP size | |||
| @@ -2756,6 +2760,7 @@ typedef struct AVCodecContext { | |||
| */ | |||
| int (*execute2)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg, int jobnr, int threadnr), void *arg2, int *ret, int count); | |||
| #if FF_API_X264_GLOBAL_OPTS | |||
| /** | |||
| * explicit P-frame weighted prediction analysis method | |||
| * 0: off | |||
| @@ -2764,7 +2769,7 @@ typedef struct AVCodecContext { | |||
| * - encoding: Set by user. | |||
| * - decoding: unused | |||
| */ | |||
| int weighted_p_pred; | |||
| attribute_deprecated int weighted_p_pred; | |||
| /** | |||
| * AQ mode | |||
| @@ -2774,7 +2779,7 @@ typedef struct AVCodecContext { | |||
| * - encoding: Set by user | |||
| * - decoding: unused | |||
| */ | |||
| int aq_mode; | |||
| attribute_deprecated int aq_mode; | |||
| /** | |||
| * AQ strength | |||
| @@ -2782,7 +2787,7 @@ typedef struct AVCodecContext { | |||
| * - encoding: Set by user | |||
| * - decoding: unused | |||
| */ | |||
| float aq_strength; | |||
| attribute_deprecated float aq_strength; | |||
| /** | |||
| * PSY RD | |||
| @@ -2790,7 +2795,7 @@ typedef struct AVCodecContext { | |||
| * - encoding: Set by user | |||
| * - decoding: unused | |||
| */ | |||
| float psy_rd; | |||
| attribute_deprecated float psy_rd; | |||
| /** | |||
| * PSY trellis | |||
| @@ -2798,7 +2803,7 @@ typedef struct AVCodecContext { | |||
| * - encoding: Set by user | |||
| * - decoding: unused | |||
| */ | |||
| float psy_trellis; | |||
| attribute_deprecated float psy_trellis; | |||
| /** | |||
| * RC lookahead | |||
| @@ -2806,7 +2811,7 @@ typedef struct AVCodecContext { | |||
| * - encoding: Set by user | |||
| * - decoding: unused | |||
| */ | |||
| int rc_lookahead; | |||
| attribute_deprecated int rc_lookahead; | |||
| /** | |||
| * Constant rate factor maximum | |||
| @@ -2815,7 +2820,8 @@ typedef struct AVCodecContext { | |||
| * - encoding: Set by user. | |||
| * - decoding: unused | |||
| */ | |||
| float crf_max; | |||
| attribute_deprecated float crf_max; | |||
| #endif | |||
| int log_level_offset; | |||
| @@ -23,6 +23,7 @@ | |||
| #include "avcodec.h" | |||
| #include "internal.h" | |||
| #include <x264.h> | |||
| #include <float.h> | |||
| #include <math.h> | |||
| #include <stdio.h> | |||
| #include <stdlib.h> | |||
| @@ -42,8 +43,17 @@ typedef struct X264Context { | |||
| char *level; | |||
| int fastfirstpass; | |||
| char *stats; | |||
| char *weightp; | |||
| char *wpredp; | |||
| char *x264opts; | |||
| float crf; | |||
| float crf_max; | |||
| int cqp; | |||
| int aq_mode; | |||
| float aq_strength; | |||
| float psy_rd; | |||
| float psy_trellis; | |||
| int rc_lookahead; | |||
| int weightp; | |||
| } X264Context; | |||
| static void X264_log(void *p, int level, const char *fmt, va_list args) | |||
| @@ -278,13 +288,7 @@ static av_cold int X264_init(AVCodecContext *avctx) | |||
| x4->params.analyse.i_me_method = X264_ME_TESA; | |||
| else x4->params.analyse.i_me_method = X264_ME_HEX; | |||
| x4->params.rc.i_aq_mode = avctx->aq_mode; | |||
| x4->params.rc.f_aq_strength = avctx->aq_strength; | |||
| x4->params.rc.i_lookahead = avctx->rc_lookahead; | |||
| x4->params.analyse.b_psy = avctx->flags2 & CODEC_FLAG2_PSY; | |||
| x4->params.analyse.f_psy_rd = avctx->psy_rd; | |||
| x4->params.analyse.f_psy_trellis = avctx->psy_trellis; | |||
| x4->params.analyse.i_me_range = avctx->me_range; | |||
| x4->params.analyse.i_subpel_refine = avctx->me_subpel_quality; | |||
| @@ -316,7 +320,7 @@ static av_cold int X264_init(AVCodecContext *avctx) | |||
| x4->params.p_log_private = avctx; | |||
| x4->params.i_log_level = X264_LOG_DEBUG; | |||
| OPT_STR("weightp", x4->weightp); | |||
| OPT_STR("weightp", x4->wpredp); | |||
| x4->params.b_intra_refresh = avctx->flags2 & CODEC_FLAG2_INTRA_REFRESH; | |||
| if (avctx->bit_rate) { | |||
| @@ -329,6 +333,7 @@ static av_cold int X264_init(AVCodecContext *avctx) | |||
| if (avctx->flags & CODEC_FLAG_PASS2) { | |||
| x4->params.rc.b_stat_read = 1; | |||
| } else { | |||
| #if FF_API_X264_GLOBAL_OPTS | |||
| if (avctx->crf) { | |||
| x4->params.rc.i_rc_method = X264_RC_CRF; | |||
| x4->params.rc.f_rf_constant = avctx->crf; | |||
| @@ -337,6 +342,18 @@ static av_cold int X264_init(AVCodecContext *avctx) | |||
| x4->params.rc.i_rc_method = X264_RC_CQP; | |||
| x4->params.rc.i_qp_constant = avctx->cqp; | |||
| } | |||
| #endif | |||
| if (x4->crf >= 0) { | |||
| x4->params.rc.i_rc_method = X264_RC_CRF; | |||
| x4->params.rc.f_rf_constant = x4->crf; | |||
| } else if (x4->cqp >= 0) { | |||
| x4->params.rc.i_rc_method = X264_RC_CQP; | |||
| x4->params.rc.i_qp_constant = x4->cqp; | |||
| } | |||
| if (x4->crf_max >= 0) | |||
| x4->params.rc.f_rf_constant_max = x4->crf_max; | |||
| } | |||
| OPT_STR("stats", x4->stats); | |||
| @@ -360,6 +377,36 @@ static av_cold int X264_init(AVCodecContext *avctx) | |||
| } | |||
| } | |||
| #if FF_API_X264_GLOBAL_OPTS | |||
| if (avctx->aq_mode >= 0) | |||
| x4->params.rc.i_aq_mode = avctx->aq_mode; | |||
| if (avctx->aq_strength >= 0) | |||
| x4->params.rc.f_aq_strength = avctx->aq_strength; | |||
| if (avctx->psy_rd >= 0) | |||
| x4->params.analyse.f_psy_rd = avctx->psy_rd; | |||
| if (avctx->psy_trellis >= 0) | |||
| x4->params.analyse.f_psy_trellis = avctx->psy_trellis; | |||
| if (avctx->rc_lookahead >= 0) | |||
| x4->params.rc.i_lookahead = avctx->rc_lookahead; | |||
| if (avctx->weighted_p_pred >= 0) | |||
| x4->params.analyse.i_weighted_pred = avctx->weighted_p_pred; | |||
| #endif | |||
| if (x4->aq_mode >= 0) | |||
| x4->params.rc.i_aq_mode = x4->aq_mode; | |||
| if (x4->aq_strength >= 0) | |||
| x4->params.rc.f_aq_strength = x4->aq_strength; | |||
| if (x4->psy_rd >= 0) | |||
| x4->params.analyse.f_psy_rd = x4->psy_rd; | |||
| if (x4->psy_trellis >= 0) | |||
| x4->params.analyse.f_psy_trellis = x4->psy_trellis; | |||
| if (x4->rc_lookahead >= 0) | |||
| x4->params.rc.i_lookahead = x4->rc_lookahead; | |||
| if (x4->weightp >= 0) | |||
| x4->params.analyse.i_weighted_pred = x4->weightp; | |||
| if (x4->fastfirstpass) | |||
| x264_param_apply_fastfirstpass(&x4->params); | |||
| @@ -398,7 +445,9 @@ static av_cold int X264_init(AVCodecContext *avctx) | |||
| avctx->has_b_frames = x4->params.i_bframe ? | |||
| x4->params.i_bframe_pyramid ? 2 : 1 : 0; | |||
| avctx->bit_rate = x4->params.rc.i_bitrate*1000; | |||
| #if FF_API_X264_GLOBAL_OPTS | |||
| avctx->crf = x4->params.rc.f_rf_constant; | |||
| #endif | |||
| x4->enc = x264_encoder_open(&x4->params); | |||
| if (!x4->enc) | |||
| @@ -433,8 +482,23 @@ static const AVOption options[] = { | |||
| { "fastfirstpass", "Use fast settings when encoding first pass", OFFSET(fastfirstpass), FF_OPT_TYPE_INT, { 1 }, 0, 1, VE}, | |||
| {"level", "Specify level (as defined by Annex A)", OFFSET(level), FF_OPT_TYPE_STRING, {.str=NULL}, 0, 0, VE}, | |||
| {"passlogfile", "Filename for 2 pass stats", OFFSET(stats), FF_OPT_TYPE_STRING, {.str=NULL}, 0, 0, VE}, | |||
| {"wpredp", "Weighted prediction for P-frames", OFFSET(weightp), FF_OPT_TYPE_STRING, {.str=NULL}, 0, 0, VE}, | |||
| {"wpredp", "Weighted prediction for P-frames", OFFSET(wpredp), FF_OPT_TYPE_STRING, {.str=NULL}, 0, 0, VE}, | |||
| {"x264opts", "x264 options", OFFSET(x264opts), FF_OPT_TYPE_STRING, {.str=NULL}, 0, 0, VE}, | |||
| { "crf", "Select the quality for constant quality mode", OFFSET(crf), FF_OPT_TYPE_FLOAT, {-1 }, -1, FLT_MAX, VE }, | |||
| { "crf_max", "In CRF mode, prevents VBV from lowering quality beyond this point.",OFFSET(crf_max), FF_OPT_TYPE_FLOAT, {-1 }, -1, FLT_MAX, VE }, | |||
| { "cqp", "Constant quantization parameter rate control method",OFFSET(cqp), FF_OPT_TYPE_INT, {-1 }, -1, INT_MAX, VE }, | |||
| { "aq_mode", "AQ method", OFFSET(aq_mode), FF_OPT_TYPE_INT, {-1 }, -1, INT_MAX, VE, "aq_mode"}, | |||
| { "none", NULL, 0, FF_OPT_TYPE_CONST, {X264_AQ_NONE}, INT_MIN, INT_MAX, VE, "aq_mode" }, | |||
| { "variance", "Variance AQ (complexity mask)", 0, FF_OPT_TYPE_CONST, {X264_AQ_VARIANCE}, INT_MIN, INT_MAX, VE, "aq_mode" }, | |||
| { "autovariance", "Auto-variance AQ (experimental)", 0, FF_OPT_TYPE_CONST, {X264_AQ_AUTOVARIANCE}, INT_MIN, INT_MAX, VE, "aq_mode" }, | |||
| { "aq_strength", "AQ strength. Reduces blocking and blurring in flat and textured areas.", OFFSET(aq_strength), FF_OPT_TYPE_FLOAT, {-1}, -1, FLT_MAX, VE}, | |||
| { "pdy_rd", "Psy RD strength.", OFFSET(psy_rd), FF_OPT_TYPE_FLOAT, {-1 }, -1, FLT_MAX, VE}, | |||
| { "psy_trellis", "Psy trellis strength", OFFSET(psy_trellis), FF_OPT_TYPE_FLOAT, {-1 }, -1, FLT_MAX, VE}, | |||
| { "rc_lookahead", "Number of frames to look ahead for frametype and ratecontrol", OFFSET(rc_lookahead), FF_OPT_TYPE_INT, {-1 }, -1, INT_MAX, VE }, | |||
| { "weightp", "Weighted prediction analysis method.", OFFSET(weightp), FF_OPT_TYPE_INT, {-1 }, -1, INT_MAX, VE, "weightp" }, | |||
| { "none", NULL, 0, FF_OPT_TYPE_CONST, {X264_WEIGHTP_NONE}, INT_MIN, INT_MAX, VE, "weightp" }, | |||
| { "simple", NULL, 0, FF_OPT_TYPE_CONST, {X264_WEIGHTP_SIMPLE}, INT_MIN, INT_MAX, VE, "weightp" }, | |||
| { "smart", NULL, 0, FF_OPT_TYPE_CONST, {X264_WEIGHTP_SMART}, INT_MIN, INT_MAX, VE, "weightp" }, | |||
| { NULL }, | |||
| }; | |||
| @@ -141,7 +141,9 @@ static const AVOption options[]={ | |||
| {"b_qfactor", "qp factor between p and b frames", OFFSET(b_quant_factor), FF_OPT_TYPE_FLOAT, {.dbl = 1.25 }, -FLT_MAX, FLT_MAX, V|E}, | |||
| {"rc_strategy", "ratecontrol method", OFFSET(rc_strategy), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, | |||
| {"b_strategy", "strategy to choose between I/P/B-frames", OFFSET(b_frame_strategy), FF_OPT_TYPE_INT, {.dbl = 0 }, INT_MIN, INT_MAX, V|E}, | |||
| {"wpredp", "weighted prediction analysis method", OFFSET(weighted_p_pred), FF_OPT_TYPE_INT, {.dbl = 0 }, INT_MIN, INT_MAX, V|E}, | |||
| #if FF_API_X264_GLOBAL_OPTS | |||
| {"wpredp", "weighted prediction analysis method", OFFSET(weighted_p_pred), FF_OPT_TYPE_INT, {.dbl = -1 }, INT_MIN, INT_MAX, V|E}, | |||
| #endif | |||
| {"ps", "rtp payload size in bytes", OFFSET(rtp_payload_size), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, | |||
| {"mv_bits", NULL, OFFSET(mv_bits), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, | |||
| {"header_bits", NULL, OFFSET(header_bits), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, | |||
| @@ -375,8 +377,10 @@ static const AVOption options[]={ | |||
| {"all" , NULL, 0, FF_OPT_TYPE_CONST, {.dbl = AVDISCARD_ALL }, INT_MIN, INT_MAX, V|D, "avdiscard"}, | |||
| {"bidir_refine", "refine the two motion vectors used in bidirectional macroblocks", OFFSET(bidir_refine), FF_OPT_TYPE_INT, {.dbl = 1 }, 0, 4, V|E}, | |||
| {"brd_scale", "downscales frames for dynamic B-frame decision", OFFSET(brd_scale), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, 10, V|E}, | |||
| #if FF_API_X264_GLOBAL_OPTS | |||
| {"crf", "enables constant quality mode, and selects the quality (x264/VP8)", OFFSET(crf), FF_OPT_TYPE_FLOAT, {.dbl = DEFAULT }, 0, 63, V|E}, | |||
| {"cqp", "constant quantization parameter rate control method", OFFSET(cqp), FF_OPT_TYPE_INT, {.dbl = -1 }, INT_MIN, INT_MAX, V|E}, | |||
| #endif | |||
| {"keyint_min", "minimum interval between IDR-frames", OFFSET(keyint_min), FF_OPT_TYPE_INT, {.dbl = 25 }, INT_MIN, INT_MAX, V|E}, | |||
| {"refs", "reference frames to consider for motion compensation", OFFSET(refs), FF_OPT_TYPE_INT, {.dbl = 1 }, INT_MIN, INT_MAX, V|E}, | |||
| {"chromaoffset", "chroma qp offset from luma", OFFSET(chromaoffset), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, | |||
| @@ -435,14 +439,18 @@ static const AVOption options[]={ | |||
| {"color_range", NULL, OFFSET(color_range), FF_OPT_TYPE_INT, {.dbl = AVCOL_RANGE_UNSPECIFIED }, 0, AVCOL_RANGE_NB-1, V|E|D}, | |||
| {"chroma_sample_location", NULL, OFFSET(chroma_sample_location), FF_OPT_TYPE_INT, {.dbl = AVCHROMA_LOC_UNSPECIFIED }, 0, AVCHROMA_LOC_NB-1, V|E|D}, | |||
| {"psy", "use psycho visual optimization", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_PSY }, INT_MIN, INT_MAX, V|E, "flags2"}, | |||
| {"psy_rd", "specify psycho visual strength", OFFSET(psy_rd), FF_OPT_TYPE_FLOAT, {.dbl = 1.0 }, 0, FLT_MAX, V|E}, | |||
| {"psy_trellis", "specify psycho visual trellis", OFFSET(psy_trellis), FF_OPT_TYPE_FLOAT, {.dbl = 0 }, 0, FLT_MAX, V|E}, | |||
| {"aq_mode", "specify aq method", OFFSET(aq_mode), FF_OPT_TYPE_INT, {.dbl = 1 }, 0, INT_MAX, V|E}, | |||
| {"aq_strength", "specify aq strength", OFFSET(aq_strength), FF_OPT_TYPE_FLOAT, {.dbl = 1.0 }, 0, FLT_MAX, V|E}, | |||
| #if FF_API_X264_GLOBAL_OPTS | |||
| {"psy_rd", "specify psycho visual strength", OFFSET(psy_rd), FF_OPT_TYPE_FLOAT, {.dbl = -1.0 }, -1, FLT_MAX, V|E}, | |||
| {"psy_trellis", "specify psycho visual trellis", OFFSET(psy_trellis), FF_OPT_TYPE_FLOAT, {.dbl = -1 }, -1, FLT_MAX, V|E}, | |||
| {"aq_mode", "specify aq method", OFFSET(aq_mode), FF_OPT_TYPE_INT, {.dbl = -1 }, -1, INT_MAX, V|E}, | |||
| {"aq_strength", "specify aq strength", OFFSET(aq_strength), FF_OPT_TYPE_FLOAT, {.dbl = -1.0 }, -1, FLT_MAX, V|E}, | |||
| {"rc_lookahead", "specify number of frames to look ahead for frametype", OFFSET(rc_lookahead), FF_OPT_TYPE_INT, {.dbl = 40 }, 0, INT_MAX, V|E}, | |||
| #endif | |||
| {"ssim", "ssim will be calculated during encoding", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_SSIM }, INT_MIN, INT_MAX, V|E, "flags2"}, | |||
| {"intra_refresh", "use periodic insertion of intra blocks instead of keyframes", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_INTRA_REFRESH }, INT_MIN, INT_MAX, V|E, "flags2"}, | |||
| #if FF_API_X264_GLOBAL_OPTS | |||
| {"crf_max", "in crf mode, prevents vbv from lowering quality beyond this point", OFFSET(crf_max), FF_OPT_TYPE_FLOAT, {.dbl = DEFAULT }, 0, 51, V|E}, | |||
| #endif | |||
| {"log_level_offset", "set the log level offset", OFFSET(log_level_offset), FF_OPT_TYPE_INT, {.dbl = 0 }, INT_MIN, INT_MAX }, | |||
| #if FF_API_FLAC_GLOBAL_OPTS | |||
| {"lpc_type", "deprecated, use flac-specific options", OFFSET(lpc_type), FF_OPT_TYPE_INT, {.dbl = AV_LPC_TYPE_DEFAULT }, AV_LPC_TYPE_DEFAULT, AV_LPC_TYPE_NB-1, A|E}, | |||
| @@ -456,7 +464,6 @@ static const AVOption options[]={ | |||
| {"thread_type", "select multithreading type", OFFSET(thread_type), FF_OPT_TYPE_INT, {.dbl = FF_THREAD_SLICE|FF_THREAD_FRAME }, 0, INT_MAX, V|E|D, "thread_type"}, | |||
| {"slice", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_THREAD_SLICE }, INT_MIN, INT_MAX, V|E|D, "thread_type"}, | |||
| {"frame", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_THREAD_FRAME }, INT_MIN, INT_MAX, V|E|D, "thread_type"}, | |||
| {"vbv_delay", "initial buffer fill time in periods of 27Mhz clock", 0, FF_OPT_TYPE_INT64, {.dbl = 0 }, 0, INT64_MAX}, | |||
| {"audio_service_type", "audio service type", OFFSET(audio_service_type), FF_OPT_TYPE_INT, {.dbl = AV_AUDIO_SERVICE_TYPE_MAIN }, 0, AV_AUDIO_SERVICE_TYPE_NB-1, A|E, "audio_service_type"}, | |||
| {"ma", "Main Audio Service", 0, FF_OPT_TYPE_CONST, {.dbl = AV_AUDIO_SERVICE_TYPE_MAIN }, INT_MIN, INT_MAX, A|E, "audio_service_type"}, | |||
| {"ef", "Effects", 0, FF_OPT_TYPE_CONST, {.dbl = AV_AUDIO_SERVICE_TYPE_EFFECTS }, INT_MIN, INT_MAX, A|E, "audio_service_type"}, | |||
| @@ -83,5 +83,8 @@ | |||
| #ifndef FF_API_AVCODEC_INIT | |||
| #define FF_API_AVCODEC_INIT (LIBAVCODEC_VERSION_MAJOR < 54) | |||
| #endif | |||
| #ifndef FF_API_X264_GLOBAL_OPTS | |||
| #define FF_API_X264_GLOBAL_OPTS (LIBAVCODEC_VERSION_MAJOR < 54) | |||
| #endif | |||
| #endif /* AVCODEC_VERSION_H */ | |||
| @@ -610,7 +610,7 @@ static int init_input(AVFormatContext *s, const char *filename) | |||
| return 0; | |||
| if ((ret = avio_open(&s->pb, filename, AVIO_FLAG_READ)) < 0) | |||
| return ret; | |||
| return ret; | |||
| if (s->iformat) | |||
| return 0; | |||
| return av_probe_input_buffer(s->pb, &s->iformat, filename, s, 0, 0); | |||
| @@ -1175,7 +1175,7 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt) | |||
| st->cur_pkt.data = NULL; | |||
| assert(st->cur_len == 0); | |||
| }else{ | |||
| pkt->destruct = NULL; | |||
| pkt->destruct = NULL; | |||
| } | |||
| compute_pkt_fields(s, st, st->parser, pkt); | |||
| @@ -1793,7 +1793,7 @@ int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int f | |||
| return -1; | |||
| st= s->streams[stream_index]; | |||
| /* timestamp for default must be expressed in AV_TIME_BASE units */ | |||
| /* timestamp for default must be expressed in AV_TIME_BASE units */ | |||
| timestamp = av_rescale(timestamp, st->time_base.den, AV_TIME_BASE * (int64_t)st->time_base.num); | |||
| } | |||
| @@ -1999,39 +1999,40 @@ static void estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset) | |||
| filesize = ic->file_size; | |||
| end_time = AV_NOPTS_VALUE; | |||
| do{ | |||
| offset = filesize - (DURATION_MAX_READ_SIZE<<retry); | |||
| if (offset < 0) | |||
| offset = 0; | |||
| offset = filesize - (DURATION_MAX_READ_SIZE<<retry); | |||
| if (offset < 0) | |||
| offset = 0; | |||
| avio_seek(ic->pb, offset, SEEK_SET); | |||
| read_size = 0; | |||
| for(;;) { | |||
| if (read_size >= DURATION_MAX_READ_SIZE<<(FFMAX(retry-1,0))) | |||
| break; | |||
| avio_seek(ic->pb, offset, SEEK_SET); | |||
| read_size = 0; | |||
| for(;;) { | |||
| if (read_size >= DURATION_MAX_READ_SIZE<<(FFMAX(retry-1,0))) | |||
| break; | |||
| do{ | |||
| ret = av_read_packet(ic, pkt); | |||
| }while(ret == AVERROR(EAGAIN)); | |||
| if (ret != 0) | |||
| break; | |||
| read_size += pkt->size; | |||
| st = ic->streams[pkt->stream_index]; | |||
| if (pkt->pts != AV_NOPTS_VALUE && | |||
| (st->start_time != AV_NOPTS_VALUE || | |||
| st->first_dts != AV_NOPTS_VALUE)) { | |||
| duration = end_time = pkt->pts; | |||
| if (st->start_time != AV_NOPTS_VALUE) duration -= st->start_time; | |||
| else duration -= st->first_dts; | |||
| if (duration < 0) | |||
| duration += 1LL<<st->pts_wrap_bits; | |||
| if (duration > 0) { | |||
| if (st->duration == AV_NOPTS_VALUE || | |||
| st->duration < duration) | |||
| st->duration = duration; | |||
| do { | |||
| ret = av_read_packet(ic, pkt); | |||
| } while(ret == AVERROR(EAGAIN)); | |||
| if (ret != 0) | |||
| break; | |||
| read_size += pkt->size; | |||
| st = ic->streams[pkt->stream_index]; | |||
| if (pkt->pts != AV_NOPTS_VALUE && | |||
| (st->start_time != AV_NOPTS_VALUE || | |||
| st->first_dts != AV_NOPTS_VALUE)) { | |||
| duration = end_time = pkt->pts; | |||
| if (st->start_time != AV_NOPTS_VALUE) | |||
| duration -= st->start_time; | |||
| else | |||
| duration -= st->first_dts; | |||
| if (duration < 0) | |||
| duration += 1LL<<st->pts_wrap_bits; | |||
| if (duration > 0) { | |||
| if (st->duration == AV_NOPTS_VALUE || st->duration < duration) | |||
| st->duration = duration; | |||
| } | |||
| } | |||
| av_free_packet(pkt); | |||
| } | |||
| av_free_packet(pkt); | |||
| } | |||
| }while( end_time==AV_NOPTS_VALUE | |||
| && filesize > (DURATION_MAX_READ_SIZE<<retry) | |||
| && ++retry <= DURATION_MAX_RETRY); | |||
| @@ -4049,7 +4050,7 @@ int avformat_query_codec(AVOutputFormat *ofmt, enum CodecID codec_id, int std_co | |||
| return !!av_codec_get_tag(ofmt->codec_tag, codec_id); | |||
| else if (codec_id == ofmt->video_codec || codec_id == ofmt->audio_codec || | |||
| codec_id == ofmt->subtitle_codec) | |||
| return 1; | |||
| return 1; | |||
| } | |||
| return AVERROR_PATCHWELCOME; | |||
| } | |||