1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-10 06:10:52 +02:00

Merge remote-tracking branch 'qatar/master'

* qatar/master:
  libx264: add 'cplxblur' private option
  libx264: add 'deblock' private option
  libx264: add 'b-bias' private option
  libx264: fix setting some options.
  libx264: remove useless assignment
  ac3dec: avoid pointless alloc and indirection for input_buffer
  mpeg12: cosmetics: reformat as K&R

Conflicts:
	libavcodec/libx264.c
	libavcodec/mpeg12.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer
2011-09-06 21:35:18 +02:00
4 changed files with 801 additions and 779 deletions

View File

@@ -2481,12 +2481,14 @@ typedef struct AVCodecContext {
*/
int chromaoffset;
#if FF_API_X264_GLOBAL_OPTS
/**
* Influences how often B-frames are used.
* - encoding: Set by user.
* - decoding: unused
*/
int bframebias;
attribute_deprecated int bframebias;
#endif
/**
* trellis RD quantization
@@ -2495,12 +2497,13 @@ typedef struct AVCodecContext {
*/
int trellis;
#if FF_API_X264_GLOBAL_OPTS
/**
* Reduce fluctuations in qp (before curve compression).
* - encoding: Set by user.
* - decoding: unused
*/
float complexityblur;
attribute_deprecated float complexityblur;
/**
* in-loop deblocking filter alphac0 parameter
@@ -2508,7 +2511,7 @@ typedef struct AVCodecContext {
* - encoding: Set by user.
* - decoding: unused
*/
int deblockalpha;
attribute_deprecated int deblockalpha;
/**
* in-loop deblocking filter beta parameter
@@ -2516,7 +2519,8 @@ typedef struct AVCodecContext {
* - encoding: Set by user.
* - decoding: unused
*/
int deblockbeta;
attribute_deprecated int deblockbeta;
#endif
/**
* macroblock subpartition sizes to consider - p8x8, p4x4, b8x8, i8x8, i4x4

View File

@@ -57,12 +57,15 @@ typedef struct X264Context {
int weightb;
int ssim;
int intra_refresh;
int b_bias;
int b_pyramid;
int mixed_refs;
int dct8x8;
int fast_pskip;
int aud;
int mbtree;
char *deblock;
float cplxblur;
} X264Context;
static void X264_log(void *p, int level, const char *fmt, va_list args)
@@ -232,39 +235,26 @@ static void check_default_settings(AVCodecContext *avctx)
} \
} while (0);
#define PARSE_X264_OPT(name, var)\
if (x4->var && x264_param_parse(&x4->params, name, x4->var) < 0) {\
av_log(avctx, AV_LOG_ERROR, "Error parsing option '%s' with value '%s'.\n", name, x4->var);\
return AVERROR(EINVAL);\
}
static av_cold int X264_init(AVCodecContext *avctx)
{
X264Context *x4 = avctx->priv_data;
x4->sei_size = 0;
x264_param_default(&x4->params);
x4->params.i_keyint_max = avctx->gop_size;
x4->params.i_bframe = avctx->max_b_frames;
x4->params.b_cabac = avctx->coder_type == FF_CODER_TYPE_AC;
x4->params.i_bframe_adaptive = avctx->b_frame_strategy;
x4->params.i_bframe_bias = avctx->bframebias;
x4->params.i_keyint_min = avctx->keyint_min;
if (x4->params.i_keyint_min > x4->params.i_keyint_max)
x4->params.i_keyint_min = x4->params.i_keyint_max;
x4->params.i_scenecut_threshold = avctx->scenechange_threshold;
x4->params.b_deblocking_filter = avctx->flags & CODEC_FLAG_LOOP_FILTER;
x4->params.i_deblocking_filter_alphac0 = avctx->deblockalpha;
x4->params.i_deblocking_filter_beta = avctx->deblockbeta;
x4->params.rc.i_qp_min = avctx->qmin;
x4->params.rc.i_qp_max = avctx->qmax;
x4->params.rc.i_qp_step = avctx->max_qdiff;
x4->params.rc.f_qcompress = avctx->qcompress; /* 0.0 => cbr, 1.0 => constant qp */
x4->params.rc.f_qblur = avctx->qblur; /* temporally blur quants */
x4->params.rc.f_complexity_blur = avctx->complexityblur;
x4->params.i_frame_reference = avctx->refs;
x4->params.analyse.inter = 0;
if (avctx->partitions) {
@@ -389,6 +379,14 @@ static av_cold int X264_init(AVCodecContext *avctx)
x4->params.rc.i_lookahead = avctx->rc_lookahead;
if (avctx->weighted_p_pred >= 0)
x4->params.analyse.i_weighted_pred = avctx->weighted_p_pred;
if (avctx->bframebias)
x4->params.i_bframe_bias = avctx->bframebias;
if (avctx->deblockalpha)
x4->params.i_deblocking_filter_alphac0 = avctx->deblockalpha;
if (avctx->deblockbeta)
x4->params.i_deblocking_filter_beta = avctx->deblockbeta;
if (avctx->complexityblur >= 0)
x4->params.rc.f_complexity_blur = avctx->complexityblur;
x4->params.analyse.b_ssim = avctx->flags2 & CODEC_FLAG2_SSIM;
x4->params.b_intra_refresh = avctx->flags2 & CODEC_FLAG2_INTRA_REFRESH;
x4->params.i_bframe_pyramid = avctx->flags2 & CODEC_FLAG2_BPYRAMID ? X264_B_PYRAMID_NORMAL : X264_B_PYRAMID_NONE;
@@ -401,14 +399,31 @@ static av_cold int X264_init(AVCodecContext *avctx)
x4->params.rc.b_mb_tree = !!(avctx->flags2 & CODEC_FLAG2_MBTREE);
#endif
if (avctx->gop_size >= 0)
x4->params.i_keyint_max = avctx->gop_size;
if (avctx->max_b_frames >= 0)
x4->params.i_bframe = avctx->max_b_frames;
if (avctx->scenechange_threshold >= 0)
x4->params.i_scenecut_threshold = avctx->scenechange_threshold;
if (avctx->qmin >= 0)
x4->params.rc.i_qp_min = avctx->qmin;
if (avctx->qmax >= 0)
x4->params.rc.i_qp_max = avctx->qmax;
if (avctx->max_qdiff >= 0)
x4->params.rc.i_qp_step = avctx->max_qdiff;
if (avctx->qblur >= 0)
x4->params.rc.f_qblur = avctx->qblur; /* temporally blur quants */
if (avctx->qcompress >= 0)
x4->params.rc.f_qcompress = avctx->qcompress; /* 0.0 => cbr, 1.0 => constant qp */
if (avctx->refs >= 0)
x4->params.i_frame_reference = avctx->refs;
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 && x264_param_parse(&x4->params, "psy-rd", x4->psy_rd) < 0) {
av_log(avctx, AV_LOG_ERROR, "Error parsing option 'psy-rd' with value '%s'.\n", x4->psy_rd);
return AVERROR(EINVAL);
}
PARSE_X264_OPT("psy-rd", psy_rd);
PARSE_X264_OPT("deblock", deblock);
if (x4->psy >= 0)
x4->params.analyse.b_psy = x4->psy;
if (x4->rc_lookahead >= 0)
@@ -417,11 +432,15 @@ static av_cold int X264_init(AVCodecContext *avctx)
x4->params.analyse.i_weighted_pred = x4->weightp;
if (x4->weightb >= 0)
x4->params.analyse.b_weighted_bipred = x4->weightb;
if (x4->cplxblur >= 0)
x4->params.rc.f_complexity_blur = x4->cplxblur;
if (x4->ssim >= 0)
x4->params.analyse.b_ssim = x4->ssim;
if (x4->intra_refresh >= 0)
x4->params.b_intra_refresh = x4->intra_refresh;
if (x4->b_bias != INT_MIN)
x4->params.i_bframe_bias = x4->b_bias;
if (x4->b_pyramid >= 0)
x4->params.i_bframe_pyramid = x4->b_pyramid;
if (x4->mixed_refs >= 0)
@@ -527,6 +546,7 @@ static const AVOption options[] = {
{ "smart", NULL, 0, FF_OPT_TYPE_CONST, {X264_WEIGHTP_SMART}, INT_MIN, INT_MAX, VE, "weightp" },
{ "ssim", "Calculate and print SSIM stats.", OFFSET(ssim), FF_OPT_TYPE_INT, {-1 }, -1, 1, VE },
{ "intra-refresh", "Use Periodic Intra Refresh instead of IDR frames.",OFFSET(intra_refresh),FF_OPT_TYPE_INT, {-1 }, -1, 1, VE },
{ "b-bias", "Influences how often B-frames are used", OFFSET(b_bias), FF_OPT_TYPE_INT, {INT_MIN}, INT_MIN, INT_MAX, VE },
{ "b-pyramid", "Keep some B-frames as references.", OFFSET(b_pyramid), FF_OPT_TYPE_INT, {-1 }, -1, INT_MAX, VE, "b_pyramid" },
{ "none", NULL, 0, FF_OPT_TYPE_CONST, {X264_B_PYRAMID_NONE}, INT_MIN, INT_MAX, VE, "b_pyramid" },
{ "strict", "Strictly hierarchical pyramid", 0, FF_OPT_TYPE_CONST, {X264_B_PYRAMID_STRICT}, INT_MIN, INT_MAX, VE, "b_pyramid" },
@@ -536,6 +556,8 @@ static const AVOption options[] = {
{ "fast-pskip", NULL, OFFSET(fast_pskip), FF_OPT_TYPE_INT, {-1 }, -1, 1, VE},
{ "aud", "Use access unit delimiters.", OFFSET(aud), FF_OPT_TYPE_INT, {-1 }, -1, 1, VE},
{ "mbtree", "Use macroblock tree ratecontrol.", OFFSET(mbtree), FF_OPT_TYPE_INT, {-1 }, -1, 1, VE},
{ "deblock", "Loop filter parameters, in <alpha:beta> form.", OFFSET(deblock), FF_OPT_TYPE_STRING, { 0 }, 0, 0, VE},
{ "cplxblur", "Reduce fluctuations in QP (before curve compression)", OFFSET(cplxblur), FF_OPT_TYPE_FLOAT, {-1 }, -1, FLT_MAX, VE},
{ NULL },
};
@@ -548,6 +570,15 @@ static const AVClass class = {
static const AVCodecDefault x264_defaults[] = {
{ "b", "0" },
{ "bf", "-1" },
{ "g", "-1" },
{ "qmin", "-1" },
{ "qmax", "-1" },
{ "qdiff", "-1" },
{ "qblur", "-1" },
{ "qcomp", "-1" },
{ "refs", "-1" },
{ "sc_threshold", "-1" },
{ "threads", AV_STRINGIFY(X264_THREADS_AUTO) },
{ NULL },
};

View File

@@ -50,19 +50,11 @@
#define MB_PTYPE_VLC_BITS 6
#define MB_BTYPE_VLC_BITS 6
static inline int mpeg1_decode_block_intra(MpegEncContext *s,
DCTELEM *block,
int n);
static inline int mpeg1_decode_block_inter(MpegEncContext *s,
DCTELEM *block,
int n);
static inline int mpeg1_decode_block_intra(MpegEncContext *s, DCTELEM *block, int n);
static inline int mpeg1_decode_block_inter(MpegEncContext *s, DCTELEM *block, int n);
static inline int mpeg1_fast_decode_block_inter(MpegEncContext *s, DCTELEM *block, int n);
static inline int mpeg2_decode_block_non_intra(MpegEncContext *s,
DCTELEM *block,
int n);
static inline int mpeg2_decode_block_intra(MpegEncContext *s,
DCTELEM *block,
int n);
static inline int mpeg2_decode_block_non_intra(MpegEncContext *s, DCTELEM *block, int n);
static inline int mpeg2_decode_block_intra(MpegEncContext *s, DCTELEM *block, int n);
static inline int mpeg2_fast_decode_block_non_intra(MpegEncContext *s, DCTELEM *block, int n);
static inline int mpeg2_fast_decode_block_intra(MpegEncContext *s, DCTELEM *block, int n);
static int mpeg_decode_motion(MpegEncContext *s, int fcode, int pred);
@@ -123,7 +115,8 @@ void ff_mpeg12_common_init(MpegEncContext *s)
}
void ff_mpeg1_clean_buffers(MpegEncContext *s){
void ff_mpeg1_clean_buffers(MpegEncContext *s)
{
s->last_dc[0] = 1 << (7 + s->intra_dc_precision);
s->last_dc[1] = s->last_dc[0];
s->last_dc[2] = s->last_dc[0];
@@ -204,8 +197,7 @@ static inline int get_qscale(MpegEncContext *s)
#define MT_16X8 2
#define MT_DMV 3
static int mpeg_decode_mb(MpegEncContext *s,
DCTELEM block[12][64])
static int mpeg_decode_mb(MpegEncContext *s, DCTELEM block[12][64])
{
int i, j, k, cbp, val, mb_type, motion_type;
const int mb_block_count = 4 + (1 << s->chroma_format);
@@ -617,9 +609,7 @@ static int mpeg_decode_motion(MpegEncContext *s, int fcode, int pred)
return val;
}
static inline int mpeg1_decode_block_intra(MpegEncContext *s,
DCTELEM *block,
int n)
static inline int mpeg1_decode_block_intra(MpegEncContext *s, DCTELEM *block, int n)
{
int level, dc, diff, i, j, run;
int component;
@@ -690,16 +680,12 @@ static inline int mpeg1_decode_block_intra(MpegEncContext *s,
return 0;
}
int ff_mpeg1_decode_block_intra(MpegEncContext *s,
DCTELEM *block,
int n)
int ff_mpeg1_decode_block_intra(MpegEncContext *s, DCTELEM *block, int n)
{
return mpeg1_decode_block_intra(s, block, n);
}
static inline int mpeg1_decode_block_inter(MpegEncContext *s,
DCTELEM *block,
int n)
static inline int mpeg1_decode_block_inter(MpegEncContext *s, DCTELEM *block, int n)
{
int level, i, j, run;
RLTable *rl = &ff_rl_mpeg1;
@@ -846,9 +832,7 @@ end:
}
static inline int mpeg2_decode_block_non_intra(MpegEncContext *s,
DCTELEM *block,
int n)
static inline int mpeg2_decode_block_non_intra(MpegEncContext *s, DCTELEM *block, int n)
{
int level, i, j, run;
RLTable *rl = &ff_rl_mpeg1;
@@ -928,8 +912,7 @@ end:
}
static inline int mpeg2_fast_decode_block_non_intra(MpegEncContext *s,
DCTELEM *block,
int n)
DCTELEM *block, int n)
{
int level, i, j, run;
RLTable *rl = &ff_rl_mpeg1;
@@ -990,9 +973,7 @@ end:
}
static inline int mpeg2_decode_block_intra(MpegEncContext *s,
DCTELEM *block,
int n)
static inline int mpeg2_decode_block_intra(MpegEncContext *s, DCTELEM *block, int n)
{
int level, dc, diff, i, j, run;
int component;
@@ -1070,9 +1051,7 @@ static inline int mpeg2_decode_block_intra(MpegEncContext *s,
return 0;
}
static inline int mpeg2_fast_decode_block_intra(MpegEncContext *s,
DCTELEM *block,
int n)
static inline int mpeg2_fast_decode_block_intra(MpegEncContext *s, DCTELEM *block, int n)
{
int level, dc, diff, j, run;
int component;
@@ -1199,14 +1178,15 @@ static int mpeg_decode_update_thread_context(AVCodecContext *avctx, const AVCode
if (!ctx->mpeg_enc_ctx_allocated)
memcpy(s + 1, s1 + 1, sizeof(Mpeg1Context) - sizeof(MpegEncContext));
if(!(s->pict_type == AV_PICTURE_TYPE_B || s->low_delay))
if (!(s->pict_type == FF_B_TYPE || s->low_delay))
s->picture_number++;
return 0;
}
static void quant_matrix_rebuild(uint16_t *matrix, const uint8_t *old_perm,
const uint8_t *new_perm){
const uint8_t *new_perm)
{
uint16_t temp_matrix[64];
int i;
@@ -1251,7 +1231,8 @@ static inline int uses_vdpau(AVCodecContext *avctx) {
return avctx->pix_fmt == PIX_FMT_VDPAU_MPEG1 || avctx->pix_fmt == PIX_FMT_VDPAU_MPEG2;
}
static enum PixelFormat mpeg_get_pixelformat(AVCodecContext *avctx){
static enum PixelFormat mpeg_get_pixelformat(AVCodecContext *avctx)
{
Mpeg1Context *s1 = avctx->priv_data;
MpegEncContext *s = &s1->mpeg_enc_ctx;
@@ -1275,13 +1256,13 @@ static enum PixelFormat mpeg_get_pixelformat(AVCodecContext *avctx){
/* Call this function when we know all parameters.
* It may be called in different places for MPEG-1 and MPEG-2. */
static int mpeg_decode_postinit(AVCodecContext *avctx){
static int mpeg_decode_postinit(AVCodecContext *avctx)
{
Mpeg1Context *s1 = avctx->priv_data;
MpegEncContext *s = &s1->mpeg_enc_ctx;
uint8_t old_permutation[64];
if (
(s1->mpeg_enc_ctx_allocated == 0)||
if ((s1->mpeg_enc_ctx_allocated == 0) ||
avctx->coded_width != s->width ||
avctx->coded_height != s->height ||
s1->save_width != s->width ||
@@ -1318,13 +1299,11 @@ static int mpeg_decode_postinit(AVCodecContext *avctx){
avctx->time_base.den = ff_frame_rate_tab[s->frame_rate_index].num;
avctx->time_base.num = ff_frame_rate_tab[s->frame_rate_index].den;
//MPEG-1 aspect
avctx->sample_aspect_ratio= av_d2q(
1.0/ff_mpeg1_aspect[s->aspect_ratio_info], 255);
avctx->sample_aspect_ratio = av_d2q(1.0/ff_mpeg1_aspect[s->aspect_ratio_info], 255);
avctx->ticks_per_frame=1;
} else {//MPEG-2
//MPEG-2 fps
av_reduce(
&s->avctx->time_base.den,
av_reduce(&s->avctx->time_base.den,
&s->avctx->time_base.num,
ff_frame_rate_tab[s->frame_rate_index].num * s1->frame_rate_ext.num*2,
ff_frame_rate_tab[s->frame_rate_index].den * s1->frame_rate_ext.den,
@@ -1333,8 +1312,7 @@ static int mpeg_decode_postinit(AVCodecContext *avctx){
//MPEG-2 aspect
if (s->aspect_ratio_info > 1) {
AVRational dar =
av_mul_q(
av_div_q(ff_mpeg2_aspect[s->aspect_ratio_info],
av_mul_q(av_div_q(ff_mpeg2_aspect[s->aspect_ratio_info],
(AVRational) {s1->pan_scan.width, s1->pan_scan.height}),
(AVRational) {s->width, s->height});
@@ -1344,16 +1322,12 @@ static int mpeg_decode_postinit(AVCodecContext *avctx){
if ((s1->pan_scan.width == 0) || (s1->pan_scan.height == 0) ||
(av_cmp_q(dar, (AVRational) {4, 3}) && av_cmp_q(dar, (AVRational) {16, 9}))) {
s->avctx->sample_aspect_ratio =
av_div_q(
ff_mpeg2_aspect[s->aspect_ratio_info],
(AVRational){s->width, s->height}
);
av_div_q(ff_mpeg2_aspect[s->aspect_ratio_info],
(AVRational) {s->width, s->height});
} else {
s->avctx->sample_aspect_ratio =
av_div_q(
ff_mpeg2_aspect[s->aspect_ratio_info],
(AVRational){s1->pan_scan.width, s1->pan_scan.height}
);
av_div_q(ff_mpeg2_aspect[s->aspect_ratio_info],
(AVRational) {s1->pan_scan.width, s1->pan_scan.height});
//issue1613 4/3 16/9 -> 16/9
//res_change_ffmpeg_aspect.ts 4/3 225/44 ->4/3
//widescreen-issue562.mpg 4/3 16/9 -> 16/9
@@ -1455,7 +1429,8 @@ static void mpeg_decode_sequence_extension(Mpeg1Context *s1)
s->avctx->rc_buffer_size += get_bits(&s->gb, 8) * 1024 * 16 << 10;
s->low_delay = get_bits1(&s->gb);
if(s->flags & CODEC_FLAG_LOW_DELAY) s->low_delay=1;
if (s->flags & CODEC_FLAG_LOW_DELAY)
s->low_delay = 1;
s1->frame_rate_ext.num = get_bits(&s->gb, 2) + 1;
s1->frame_rate_ext.den = get_bits(&s->gb, 5) + 1;
@@ -1524,11 +1499,11 @@ static void mpeg_decode_picture_display_extension(Mpeg1Context *s1)
av_log(s->avctx, AV_LOG_DEBUG, "pde (%d,%d) (%d,%d) (%d,%d)\n",
s1->pan_scan.position[0][0], s1->pan_scan.position[0][1],
s1->pan_scan.position[1][0], s1->pan_scan.position[1][1],
s1->pan_scan.position[2][0], s1->pan_scan.position[2][1]
);
s1->pan_scan.position[2][0], s1->pan_scan.position[2][1]);
}
static int load_matrix(MpegEncContext *s, uint16_t matrix0[64], uint16_t matrix1[64], int intra){
static int load_matrix(MpegEncContext *s, uint16_t matrix0[64], uint16_t matrix1[64], int intra)
{
int i;
for (i = 0; i < 64; i++) {
@@ -1635,7 +1610,8 @@ static void mpeg_decode_picture_coding_extension(Mpeg1Context *s1)
av_dlog(s->avctx, "progressive_frame=%d\n", s->progressive_frame);
}
static void exchange_uv(MpegEncContext *s){
static void exchange_uv(MpegEncContext *s)
{
DCTELEM (*tmp)[64];
tmp = s->pblocks[4];
@@ -1643,7 +1619,8 @@ static void exchange_uv(MpegEncContext *s){
s->pblocks[5] = tmp;
}
static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size){
static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size)
{
AVCodecContext *avctx = s->avctx;
Mpeg1Context *s1 = (Mpeg1Context*)s;
@@ -1714,8 +1691,8 @@ static int mpeg_decode_slice(Mpeg1Context *s1, int mb_y,
{
MpegEncContext *s = &s1->mpeg_enc_ctx;
AVCodecContext *avctx = s->avctx;
const int field_pic= s->picture_structure != PICT_FRAME;
const int lowres = s->avctx->lowres;
const int field_pic = s->picture_structure != PICT_FRAME;
s->resync_mb_x =
s->resync_mb_y = -1;
@@ -1931,7 +1908,8 @@ eos: // end of slice
return 0;
}
static int slice_decode_thread(AVCodecContext *c, void *arg){
static int slice_decode_thread(AVCodecContext *c, void *arg)
{
MpegEncContext *s = *(void**)arg;
const uint8_t *buf = s->gb.buffer;
int mb_y = s->start_mb_y;
@@ -2088,7 +2066,8 @@ static int mpeg1_decode_sequence(AVCodecContext *avctx,
avctx->sub_id = 1; /* indicates MPEG-1 */
s->out_format = FMT_MPEG1;
s->swap_uv = 0; // AFAIK VCR2 does not have SEQ_HEADER
if(s->flags & CODEC_FLAG_LOW_DELAY) s->low_delay=1;
if (s->flags & CODEC_FLAG_LOW_DELAY)
s->low_delay = 1;
if (s->avctx->debug & FF_DEBUG_PICT_INFO)
av_log(s->avctx, AV_LOG_DEBUG, "vbv buffer: %d, bitrate:%d\n",
@@ -2174,7 +2153,8 @@ static void mpeg_decode_user_data(AVCodecContext *avctx,
}
static void mpeg_decode_gop(AVCodecContext *avctx,
const uint8_t *buf, int buf_size){
const uint8_t *buf, int buf_size)
{
Mpeg1Context *s1 = avctx->priv_data;
MpegEncContext *s = &s1->mpeg_enc_ctx;
@@ -2230,8 +2210,10 @@ int ff_mpeg1_find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size,
if (state == EXT_START_CODE && (buf[i] & 0xF0) != 0x80)
pc->frame_start_found--;
else if (state == EXT_START_CODE + 2) {
if((buf[i]&3) == 3) pc->frame_start_found= 0;
else pc->frame_start_found= (pc->frame_start_found+1)&3;
if ((buf[i] & 3) == 3)
pc->frame_start_found = 0;
else
pc->frame_start_found = (pc->frame_start_found + 1) & 3;
}
state++;
} else {
@@ -2360,8 +2342,7 @@ static int decode_chunks(AVCodecContext *avctx,
switch (start_code) {
case SEQ_START_CODE:
if (last_code == 0) {
mpeg1_decode_sequence(avctx, buf_ptr,
input_size);
mpeg1_decode_sequence(avctx, buf_ptr, input_size);
s->sync=1;
} else {
av_log(avctx, AV_LOG_ERROR, "ignoring SEQ_START_CODE after %X\n", last_code);
@@ -2433,8 +2414,7 @@ static int decode_chunks(AVCodecContext *avctx,
}
break;
case USER_START_CODE:
mpeg_decode_user_data(avctx,
buf_ptr, input_size);
mpeg_decode_user_data(avctx, buf_ptr, input_size);
break;
case GOP_START_CODE:
if (last_code == 0) {
@@ -2475,12 +2455,13 @@ static int decode_chunks(AVCodecContext *avctx,
/* Skip P-frames if we do not have a reference frame or we have an invalid header. */
if (s2->pict_type == AV_PICTURE_TYPE_P && !s->sync) break;
}
if( (avctx->skip_frame >= AVDISCARD_NONREF && s2->pict_type==AV_PICTURE_TYPE_B)
||(avctx->skip_frame >= AVDISCARD_NONKEY && s2->pict_type!=AV_PICTURE_TYPE_I)
|| avctx->skip_frame >= AVDISCARD_ALL)
if ((avctx->skip_frame >= AVDISCARD_NONREF && s2->pict_type == AV_PICTURE_TYPE_B) ||
(avctx->skip_frame >= AVDISCARD_NONKEY && s2->pict_type != AV_PICTURE_TYPE_I) ||
avctx->skip_frame >= AVDISCARD_ALL)
break;
if (!s->mpeg_enc_ctx_allocated) break;
if (!s->mpeg_enc_ctx_allocated)
break;
if (s2->codec_id == CODEC_ID_MPEG2VIDEO) {
if (mb_y < avctx->skip_top || mb_y >= s2->mb_height - avctx->skip_bottom)
@@ -2544,7 +2525,8 @@ static int decode_chunks(AVCodecContext *avctx,
}
}
static void flush(AVCodecContext *avctx){
static void flush(AVCodecContext *avctx)
{
Mpeg1Context *s = avctx->priv_data;
s->sync=0;
@@ -2620,7 +2602,8 @@ AVCodec ff_mpegvideo_decoder = {
};
#if CONFIG_MPEG_XVMC_DECODER
static av_cold int mpeg_mc_decode_init(AVCodecContext *avctx){
static av_cold int mpeg_mc_decode_init(AVCodecContext *avctx)
{
if (avctx->active_thread_type & FF_THREAD_SLICE)
return -1;
if (!(avctx->slice_flags & SLICE_FLAG_CODED_ORDER))

View File

@@ -147,11 +147,11 @@ static const AVOption options[]={
{"frame_number", NULL, OFFSET(frame_number), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX},
{"delay", NULL, OFFSET(delay), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX},
{"qcomp", "video quantizer scale compression (VBR)", OFFSET(qcompress), FF_OPT_TYPE_FLOAT, {.dbl = 0.5 }, -FLT_MAX, FLT_MAX, V|E},
{"qblur", "video quantizer scale blur (VBR)", OFFSET(qblur), FF_OPT_TYPE_FLOAT, {.dbl = 0.5 }, 0, FLT_MAX, V|E},
{"qmin", "min video quantizer scale (VBR)", OFFSET(qmin), FF_OPT_TYPE_INT, {.dbl = 2 }, 0, 69, V|E},
{"qmax", "max video quantizer scale (VBR)", OFFSET(qmax), FF_OPT_TYPE_INT, {.dbl = 31 }, 0, 69, V|E},
{"qblur", "video quantizer scale blur (VBR)", OFFSET(qblur), FF_OPT_TYPE_FLOAT, {.dbl = 0.5 }, -1, FLT_MAX, V|E},
{"qmin", "min video quantizer scale (VBR)", OFFSET(qmin), FF_OPT_TYPE_INT, {.dbl = 2 }, -1, 69, V|E},
{"qmax", "max video quantizer scale (VBR)", OFFSET(qmax), FF_OPT_TYPE_INT, {.dbl = 31 }, -1, 69, V|E},
{"qdiff", "max difference between the quantizer scale (VBR)", OFFSET(max_qdiff), FF_OPT_TYPE_INT, {.dbl = 3 }, INT_MIN, INT_MAX, V|E},
{"bf", "use 'frames' B frames", OFFSET(max_b_frames), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, FF_MAX_B_FRAMES, V|E},
{"bf", "use 'frames' B frames", OFFSET(max_b_frames), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, -1, FF_MAX_B_FRAMES, V|E},
{"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},
@@ -398,7 +398,9 @@ static const AVOption options[]={
{"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},
#if FF_API_X264_GLOBAL_OPTS
{"bframebias", "influences how often B-frames are used", OFFSET(bframebias), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E},
#endif
{"trellis", "rate-distortion optimal quantization", OFFSET(trellis), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|A|E},
{"directpred", "direct mv prediction mode - 0 (none), 1 (spatial), 2 (temporal), 3 (auto)", OFFSET(directpred), FF_OPT_TYPE_INT, {.dbl = 2 }, INT_MIN, INT_MAX, V|E},
#if FF_API_X264_GLOBAL_OPTS
@@ -410,9 +412,11 @@ static const AVOption options[]={
{"aud", "access unit delimiters (H.264)", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_AUD }, INT_MIN, INT_MAX, V|E, "flags2"},
#endif
{"skiprd", "RD optimal MB level residual skipping", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_SKIP_RD }, INT_MIN, INT_MAX, V|E, "flags2"},
{"complexityblur", "reduce fluctuations in qp (before curve compression)", OFFSET(complexityblur), FF_OPT_TYPE_FLOAT, {.dbl = 20.0 }, FLT_MIN, FLT_MAX, V|E},
#if FF_API_X264_GLOBAL_OPTS
{"complexityblur", "reduce fluctuations in qp (before curve compression)", OFFSET(complexityblur), FF_OPT_TYPE_FLOAT, {.dbl = -1 }, -1, FLT_MAX, V|E},
{"deblockalpha", "in-loop deblocking filter alphac0 parameter", OFFSET(deblockalpha), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, -6, 6, V|E},
{"deblockbeta", "in-loop deblocking filter beta parameter", OFFSET(deblockbeta), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, -6, 6, V|E},
#endif
{"partitions", "macroblock subpartition sizes to consider", OFFSET(partitions), FF_OPT_TYPE_FLAGS, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E, "partitions"},
{"parti4x4", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = X264_PART_I4X4 }, INT_MIN, INT_MAX, V|E, "partitions"},
{"parti8x8", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = X264_PART_I8X8 }, INT_MIN, INT_MAX, V|E, "partitions"},