}
}
-static const enum PixelFormat pixfmt_xvmc_mpg2_420[] = {
- PIX_FMT_XVMC_MPEG2_IDCT,
- PIX_FMT_XVMC_MPEG2_MC,
- PIX_FMT_NONE };
+static const enum AVPixelFormat pixfmt_xvmc_mpg2_420[] = {
+ AV_PIX_FMT_XVMC_MPEG2_IDCT,
+ AV_PIX_FMT_XVMC_MPEG2_MC,
+ AV_PIX_FMT_NONE };
-static enum PixelFormat mpeg_get_pixelformat(AVCodecContext *avctx)
+static enum AVPixelFormat mpeg_get_pixelformat(AVCodecContext *avctx)
{
Mpeg1Context *s1 = avctx->priv_data;
MpegEncContext *s = &s1->mpeg_enc_ctx;
return avctx->get_format(avctx, pixfmt_xvmc_mpg2_420);
else if (avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU) {
if (avctx->codec_id == AV_CODEC_ID_MPEG1VIDEO)
- return PIX_FMT_VDPAU_MPEG1;
+ return AV_PIX_FMT_VDPAU_MPEG1;
else
- return PIX_FMT_VDPAU_MPEG2;
+ return AV_PIX_FMT_VDPAU_MPEG2;
} else {
if (s->chroma_format < 2)
return avctx->get_format(avctx, ff_hwaccel_pixfmt_list_420);
else if (s->chroma_format == 2)
- return PIX_FMT_YUV422P;
+ return AV_PIX_FMT_YUV422P;
else
- return PIX_FMT_YUV444P;
+ return AV_PIX_FMT_YUV444P;
}
}
if (avctx->codec_id == AV_CODEC_ID_MPEG1VIDEO) {
//MPEG-1 fps
- avctx->time_base.den = avpriv_frame_rate_tab[s->frame_rate_index].num;
- avctx->time_base.num = avpriv_frame_rate_tab[s->frame_rate_index].den;
+ avctx->time_base.den = ff_mpeg12_frame_rate_tab[s->frame_rate_index].num;
+ avctx->time_base.num = ff_mpeg12_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->ticks_per_frame=1;
//MPEG-2 fps
av_reduce(&s->avctx->time_base.den,
&s->avctx->time_base.num,
- avpriv_frame_rate_tab[s->frame_rate_index].num * s1->frame_rate_ext.num*2,
- avpriv_frame_rate_tab[s->frame_rate_index].den * s1->frame_rate_ext.den,
+ ff_mpeg12_frame_rate_tab[s->frame_rate_index].num * s1->frame_rate_ext.num*2,
+ ff_mpeg12_frame_rate_tab[s->frame_rate_index].den * s1->frame_rate_ext.den,
1 << 30);
avctx->ticks_per_frame = 2;
//MPEG-2 aspect
//res_change_ffmpeg_aspect.ts 4/3 225/44 ->4/3
//widescreen-issue562.mpg 4/3 16/9 -> 16/9
// s->avctx->sample_aspect_ratio = av_mul_q(s->avctx->sample_aspect_ratio, (AVRational) {s->width, s->height});
-//av_log(NULL, AV_LOG_ERROR, "A %d/%d\n", ff_mpeg2_aspect[s->aspect_ratio_info].num, ff_mpeg2_aspect[s->aspect_ratio_info].den);
-//av_log(NULL, AV_LOG_ERROR, "B %d/%d\n", s->avctx->sample_aspect_ratio.num, s->avctx->sample_aspect_ratio.den);
+ av_dlog(avctx, "A %d/%d\n",
+ ff_mpeg2_aspect[s->aspect_ratio_info].num, ff_mpeg2_aspect[s->aspect_ratio_info].den);
+ av_dlog(avctx, "B %d/%d\n", s->avctx->sample_aspect_ratio.num,
+ s->avctx->sample_aspect_ratio.den);
}
} else {
s->avctx->sample_aspect_ratio =
avctx->pix_fmt = mpeg_get_pixelformat(avctx);
avctx->hwaccel = ff_find_hwaccel(avctx->codec->id, avctx->pix_fmt);
// until then pix_fmt may be changed right after codec init
- if (avctx->pix_fmt == PIX_FMT_XVMC_MPEG2_IDCT ||
+ if (avctx->pix_fmt == AV_PIX_FMT_XVMC_MPEG2_IDCT ||
avctx->hwaccel ||
s->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU)
if (avctx->idct_algo == FF_IDCT_AUTO)
}
eos: // end of slice
*buf += (get_bits_count(&s->gb)-1)/8;
-//printf("y %d %d %d %d\n", s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y);
+ av_dlog(s, "y %d %d %d %d\n", s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y);
return 0;
}
ret = mpeg_decode_slice(s, mb_y, &buf, s->gb.buffer_end - buf);
emms_c();
-//av_log(c, AV_LOG_DEBUG, "ret:%d resync:%d/%d mb:%d/%d ts:%d/%d ec:%d\n",
-//ret, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, s->start_mb_y, s->end_mb_y, s->error_count);
+ av_dlog(c, "ret:%d resync:%d/%d mb:%d/%d ts:%d/%d ec:%d\n",
+ ret, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y,
+ s->start_mb_y, s->end_mb_y, s->error_count);
if (ret < 0) {
if (c->err_recognition & AV_EF_EXPLODE)
return ret;
avctx->pix_fmt = mpeg_get_pixelformat(avctx);
avctx->hwaccel = ff_find_hwaccel(avctx->codec->id, avctx->pix_fmt);
- if (avctx->pix_fmt == PIX_FMT_XVMC_MPEG2_IDCT || avctx->hwaccel ||
+ if (avctx->pix_fmt == AV_PIX_FMT_XVMC_MPEG2_IDCT || avctx->hwaccel ||
s->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU)
if (avctx->idct_algo == FF_IDCT_AUTO)
avctx->idct_algo = FF_IDCT_SIMPLE;
}
static int decode_chunks(AVCodecContext *avctx,
- AVFrame *picture, int *data_size,
- const uint8_t *buf, int buf_size);
-
-/* handle buffering and image synchronisation */
-static int mpeg_decode_frame(AVCodecContext *avctx,
- void *data, int *data_size,
- AVPacket *avpkt)
-{
- const uint8_t *buf = avpkt->data;
- int buf_size = avpkt->size;
- Mpeg1Context *s = avctx->priv_data;
- AVFrame *picture = data;
- MpegEncContext *s2 = &s->mpeg_enc_ctx;
- av_dlog(avctx, "fill_buffer\n");
-
- 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 = s2->next_picture_ptr->f;
- s2->next_picture_ptr = NULL;
-
- *data_size = sizeof(AVFrame);
- }
- return buf_size;
- }
-
- if (s2->flags & CODEC_FLAG_TRUNCATED) {
- int next = ff_mpeg1_find_frame_end(&s2->parse_context, buf, buf_size, NULL);
-
- if (ff_combine_frame(&s2->parse_context, next, (const uint8_t **)&buf, &buf_size) < 0)
- return buf_size;
- }
-
- if (s->mpeg_enc_ctx_allocated == 0 && avctx->codec_tag == AV_RL32("VCR2"))
- vcr2_init_sequence(avctx);
-
- s->slice_count = 0;
-
- if (avctx->extradata && !avctx->frame_number) {
- int ret = decode_chunks(avctx, picture, data_size, avctx->extradata, avctx->extradata_size);
- if (ret < 0 && (avctx->err_recognition & AV_EF_EXPLODE))
- return ret;
- }
-
- return decode_chunks(avctx, picture, data_size, buf, buf_size);
-}
-
-static int decode_chunks(AVCodecContext *avctx,
- AVFrame *picture, int *data_size,
+ AVFrame *picture, int *got_output,
const uint8_t *buf, int buf_size)
{
Mpeg1Context *s = avctx->priv_data;
if (slice_end(avctx, picture)) {
if (s2->last_picture_ptr || s2->low_delay) //FIXME merge with the stuff in mpeg_decode_slice
- *data_size = sizeof(AVPicture);
+ *got_output = 1;
}
}
s2->pict_type = 0;
thread_context->end_mb_y = s2->mb_height;
if (s->slice_count) {
s2->thread_context[s->slice_count-1]->end_mb_y = mb_y;
- ff_update_duplicate_context(thread_context, s2);
+ ret = ff_update_duplicate_context(thread_context,
+ s2);
+ if (ret < 0)
+ return ret;
}
init_get_bits(&thread_context->gb, buf_ptr, input_size*8);
s->slice_count++;
}
}
+static int mpeg_decode_frame(AVCodecContext *avctx,
+ void *data, int *got_output,
+ AVPacket *avpkt)
+{
+ const uint8_t *buf = avpkt->data;
+ int buf_size = avpkt->size;
+ Mpeg1Context *s = avctx->priv_data;
+ AVFrame *picture = data;
+ MpegEncContext *s2 = &s->mpeg_enc_ctx;
+ av_dlog(avctx, "fill_buffer\n");
+
+ 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 = s2->next_picture_ptr->f;
+ s2->next_picture_ptr = NULL;
+
+ *got_output = 1;
+ }
+ return buf_size;
+ }
+
+ if (s2->flags & CODEC_FLAG_TRUNCATED) {
+ int next = ff_mpeg1_find_frame_end(&s2->parse_context, buf, buf_size, NULL);
+
+ if (ff_combine_frame(&s2->parse_context, next, (const uint8_t **)&buf, &buf_size) < 0)
+ return buf_size;
+ }
+
+ if (s->mpeg_enc_ctx_allocated == 0 && avctx->codec_tag == AV_RL32("VCR2"))
+ vcr2_init_sequence(avctx);
+
+ s->slice_count = 0;
+
+ if (avctx->extradata && !s->extradata_decoded) {
+ int ret = decode_chunks(avctx, picture, got_output, avctx->extradata, avctx->extradata_size);
+ s->extradata_decoded = 1;
+ if (ret < 0 && (avctx->err_recognition & AV_EF_EXPLODE))
+ return ret;
+ }
+
+ return decode_chunks(avctx, picture, got_output, buf, buf_size);
+}
+
+
static void flush(AVCodecContext *avctx)
{
Mpeg1Context *s = avctx->priv_data;
}
mpeg_decode_init(avctx);
- avctx->pix_fmt = PIX_FMT_XVMC_MPEG2_IDCT;
+ avctx->pix_fmt = AV_PIX_FMT_XVMC_MPEG2_IDCT;
avctx->xvmc_acceleration = 2; // 2 - the blocks are packed!
return 0;