INIT_VLC_STATIC(&mb_btype_vlc, MB_BTYPE_VLC_BITS, 11,
&table_mb_btype[0][1], 2, 1,
&table_mb_btype[0][0], 2, 1, 64);
- init_rl(&ff_rl_mpeg1, ff_mpeg12_static_rl_table_store[0]);
- init_rl(&ff_rl_mpeg2, ff_mpeg12_static_rl_table_store[1]);
+ ff_init_rl(&ff_rl_mpeg1, ff_mpeg12_static_rl_table_store[0]);
+ ff_init_rl(&ff_rl_mpeg2, ff_mpeg12_static_rl_table_store[1]);
INIT_2D_VLC_RL(ff_rl_mpeg1, 680);
INIT_2D_VLC_RL(ff_rl_mpeg2, 674);
for (i = 0; i < 64; i++)
s2->dsp.idct_permutation[i]=i;
- MPV_decode_defaults(s2);
+ ff_MPV_decode_defaults(s2);
s->mpeg_enc_ctx.avctx = avctx;
s->mpeg_enc_ctx.flags = avctx->flags;
if (s1->mpeg_enc_ctx_allocated) {
ParseContext pc = s->parse_context;
s->parse_context.buffer = 0;
- MPV_common_end(s);
+ ff_MPV_common_end(s);
s->parse_context = pc;
}
/* low_delay may be forced, in this case we will have B-frames
* that behave like P-frames. */
- avctx->has_b_frames = !(s->low_delay);
+ avctx->has_b_frames = !s->low_delay;
- assert((avctx->sub_id == 1) == (avctx->codec_id == CODEC_ID_MPEG1VIDEO));
if (avctx->codec_id == CODEC_ID_MPEG1VIDEO) {
//MPEG-1 fps
avctx->time_base.den = avpriv_frame_rate_tab[s->frame_rate_index].num;
* if DCT permutation is changed. */
memcpy(old_permutation, s->dsp.idct_permutation, 64 * sizeof(uint8_t));
- if (MPV_common_init(s) < 0)
+ if (ff_MPV_common_init(s) < 0)
return -2;
quant_matrix_rebuild(s->intra_matrix, old_permutation, s->dsp.idct_permutation);
av_dlog(s->avctx, "sequence extension\n");
s->codec_id = s->avctx->codec_id = CODEC_ID_MPEG2VIDEO;
- s->avctx->sub_id = 2; /* indicates MPEG-2 found */
if (s->avctx->debug & FF_DEBUG_PICT_INFO)
av_log(s->avctx, AV_LOG_DEBUG, "profile: %d, level: %d vbv buffer: %d, bitrate:%d\n",
}
if (s->progressive_sequence && !s->frame_pred_frame_dct) {
- av_log(s->avctx, AV_LOG_ERROR, "invalid frame_pred_frame_dct\n");
- s->frame_pred_frame_dct = 1;
+ av_log(s->avctx, AV_LOG_WARNING, "invalid frame_pred_frame_dct\n");
}
if (s->picture_structure == PICT_FRAME) {
/* start frame decoding */
if (s->first_field || s->picture_structure == PICT_FRAME) {
- if (MPV_frame_start(s, avctx) < 0)
+ if (ff_MPV_frame_start(s, avctx) < 0)
return -1;
ff_er_frame_start(s);
return -1;
}
+ if (s->avctx->hwaccel &&
+ (s->avctx->slice_flags & SLICE_FLAG_ALLOW_FIELD)) {
+ if (s->avctx->hwaccel->end_frame(s->avctx) < 0)
+ av_log(avctx, AV_LOG_ERROR, "hardware accelerator failed to decode first field\n");
+ }
+
for (i = 0; i < 4; i++) {
s->current_picture.f.data[i] = s->current_picture_ptr->f.data[i];
if (s->picture_structure == PICT_BOTTOM_FIELD) {
const uint8_t **buf, int buf_size)
{
AVCodecContext *avctx = s->avctx;
- const int lowres = s->avctx->lowres;
const int field_pic = s->picture_structure != PICT_FRAME;
s->resync_mb_x =
if (mb_y == 0 && s->codec_tag == AV_RL32("SLIF")) {
skip_bits1(&s->gb);
} else {
- for (;;) {
+ while (get_bits_left(&s->gb) > 0) {
int code = get_vlc2(&s->gb, mbincr_vlc.table, MBINCR_VLC_BITS, 2);
if (code < 0) {
av_log(s->avctx, AV_LOG_ERROR, "first mb_incr damaged\n");
}
}
- s->dest[0] += 16 >> lowres;
- s->dest[1] +=(16 >> lowres) >> s->chroma_x_shift;
- s->dest[2] +=(16 >> lowres) >> s->chroma_x_shift;
+ s->dest[0] += 16;
+ s->dest[1] += 16 >> s->chroma_x_shift;
+ s->dest[2] += 16 >> s->chroma_x_shift;
- MPV_decode_mb(s, s->block);
+ ff_MPV_decode_mb(s, s->block);
if (++s->mb_x >= s->mb_width) {
- const int mb_size = 16 >> s->avctx->lowres;
+ const int mb_size = 16;
ff_draw_horiz_band(s, mb_size*(s->mb_y >> field_pic), mb_size);
- MPV_report_decode_progress(s);
+ ff_MPV_report_decode_progress(s);
s->mb_x = 0;
s->mb_y += 1 << field_pic;
ff_er_frame_end(s);
- MPV_frame_end(s);
+ ff_MPV_frame_end(s);
if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {
- *pict = *(AVFrame*)s->current_picture_ptr;
+ *pict = s->current_picture_ptr->f;
ff_print_debug_info(s, pict);
} else {
if (avctx->active_thread_type & FF_THREAD_FRAME)
/* latency of 1 frame for I- and P-frames */
/* XXX: use another variable than picture_number */
if (s->last_picture_ptr != NULL) {
- *pict = *(AVFrame*)s->last_picture_ptr;
+ *pict = s->last_picture_ptr->f;
ff_print_debug_info(s, pict);
}
}
s->frame_pred_frame_dct = 1;
s->chroma_format = 1;
s->codec_id = s->avctx->codec_id = CODEC_ID_MPEG1VIDEO;
- 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)
/* start new MPEG-1 context decoding */
s->out_format = FMT_MPEG1;
if (s1->mpeg_enc_ctx_allocated) {
- MPV_common_end(s);
+ ff_MPV_common_end(s);
}
s->width = avctx->coded_width;
s->height = avctx->coded_height;
if (avctx->idct_algo == FF_IDCT_AUTO)
avctx->idct_algo = FF_IDCT_SIMPLE;
- if (MPV_common_init(s) < 0)
+ if (ff_MPV_common_init(s) < 0)
return -1;
exchange_uv(s); // common init reset pblocks, so we swap them here
s->swap_uv = 1; // in case of xvmc we need to swap uv for each MB
s->frame_pred_frame_dct = 1;
s->chroma_format = 1;
s->codec_id = s->avctx->codec_id = CODEC_ID_MPEG2VIDEO;
- avctx->sub_id = 2; /* indicates MPEG-2 */
s1->save_width = s->width;
s1->save_height = s->height;
s1->save_progressive_seq = s->progressive_sequence;
pc->frame_start_found = 4;
}
if (state == SEQ_END_CODE) {
+ pc->frame_start_found = 0;
pc->state=-1;
return i+1;
}
if (buf_size == 0 || (buf_size == 4 && AV_RB32(buf) == SEQ_END_CODE)) {
/* special case for last picture */
if (s2->low_delay == 0 && s2->next_picture_ptr) {
- *picture = *(AVFrame*)s2->next_picture_ptr;
+ *picture = s2->next_picture_ptr->f;
s2->next_picture_ptr = NULL;
*data_size = sizeof(AVFrame);
}
if (HAVE_THREADS && (avctx->active_thread_type & FF_THREAD_SLICE)) {
- int threshold= (s2->mb_height * s->slice_count + avctx->thread_count / 2) / avctx->thread_count;
+ int threshold = (s2->mb_height * s->slice_count +
+ s2->slice_context_count / 2) /
+ s2->slice_context_count;
if (threshold <= mb_y) {
MpegEncContext *thread_context = s2->thread_context[s->slice_count];
Mpeg1Context *s = avctx->priv_data;
if (s->mpeg_enc_ctx_allocated)
- MPV_common_end(&s->mpeg_enc_ctx);
+ ff_MPV_common_end(&s->mpeg_enc_ctx);
return 0;
}
AVCodec ff_mpeg1video_decoder = {
- .name = "mpeg1video",
- .type = AVMEDIA_TYPE_VIDEO,
- .id = CODEC_ID_MPEG1VIDEO,
- .priv_data_size = sizeof(Mpeg1Context),
- .init = mpeg_decode_init,
- .close = mpeg_decode_end,
- .decode = mpeg_decode_frame,
- .capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY | CODEC_CAP_SLICE_THREADS,
- .flush = flush,
- .max_lowres = 3,
- .long_name = NULL_IF_CONFIG_SMALL("MPEG-1 video"),
+ .name = "mpeg1video",
+ .type = AVMEDIA_TYPE_VIDEO,
+ .id = CODEC_ID_MPEG1VIDEO,
+ .priv_data_size = sizeof(Mpeg1Context),
+ .init = mpeg_decode_init,
+ .close = mpeg_decode_end,
+ .decode = mpeg_decode_frame,
+ .capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 |
+ CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY |
+ CODEC_CAP_SLICE_THREADS,
+ .flush = flush,
+ .long_name = NULL_IF_CONFIG_SMALL("MPEG-1 video"),
.update_thread_context = ONLY_IF_THREADS_ENABLED(mpeg_decode_update_thread_context)
};
.init = mpeg_decode_init,
.close = mpeg_decode_end,
.decode = mpeg_decode_frame,
- .capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY | CODEC_CAP_SLICE_THREADS,
+ .capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 |
+ CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY |
+ CODEC_CAP_SLICE_THREADS,
.flush = flush,
- .max_lowres = 3,
.long_name = NULL_IF_CONFIG_SMALL("MPEG-2 video"),
.profiles = NULL_IF_CONFIG_SMALL(mpeg2_video_profiles),
};
.init = mpeg_mc_decode_init,
.close = mpeg_decode_end,
.decode = mpeg_decode_frame,
- .capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED| CODEC_CAP_HWACCEL | CODEC_CAP_DELAY,
+ .capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 |
+ CODEC_CAP_TRUNCATED| CODEC_CAP_HWACCEL | CODEC_CAP_DELAY,
.flush = flush,
.long_name = NULL_IF_CONFIG_SMALL("MPEG-1/2 video XvMC (X-Video Motion Compensation)"),
};
.init = mpeg_decode_init,
.close = mpeg_decode_end,
.decode = mpeg_decode_frame,
- .capabilities = CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_HWACCEL_VDPAU | CODEC_CAP_DELAY,
+ .capabilities = CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED |
+ CODEC_CAP_HWACCEL_VDPAU | CODEC_CAP_DELAY,
.flush = flush,
.long_name = NULL_IF_CONFIG_SMALL("MPEG-1/2 video (VDPAU acceleration)"),
};
.init = mpeg_decode_init,
.close = mpeg_decode_end,
.decode = mpeg_decode_frame,
- .capabilities = CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_HWACCEL_VDPAU | CODEC_CAP_DELAY,
+ .capabilities = CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED |
+ CODEC_CAP_HWACCEL_VDPAU | CODEC_CAP_DELAY,
.flush = flush,
.long_name = NULL_IF_CONFIG_SMALL("MPEG-1 video (VDPAU acceleration)"),
};
#endif
-