s->dest[1] = s->current_picture.f->data[1] + (s->mb_y * (16 >> s->chroma_y_shift) * s->uvlinesize) + s->mb_x * (16 >> s->chroma_x_shift);
s->dest[2] = s->current_picture.f->data[2] + (s->mb_y * (16 >> s->chroma_y_shift) * s->uvlinesize) + s->mb_x * (16 >> s->chroma_x_shift);
- assert(ref == 0);
+ if (ref)
+ av_log(s->avctx, AV_LOG_DEBUG,
+ "Interlaced error concealment is not fully implemented\n");
ff_mpv_decode_mb(s, s->block);
}
{
ff_blockdsp_init(&s->bdsp, s->avctx);
ff_hpeldsp_init(&s->hdsp, s->avctx->flags);
- ff_me_cmp_init(&s->mecc, s->avctx);
ff_mpegvideodsp_init(&s->mdsp);
ff_videodsp_init(&s->vdsp, s->avctx->bits_per_raw_sample);
static void free_duplicate_context(MpegEncContext *s)
{
- if (s == NULL)
+ if (!s)
return;
av_freep(&s->edge_emu_buffer);
// FIXME can parameters change on I-frames?
// in that case dst may need a reinit
if (!s->context_initialized) {
+ int err;
memcpy(s, s1, sizeof(MpegEncContext));
s->avctx = dst;
s->bitstream_buffer_size = s->allocated_bitstream_buffer_size = 0;
ff_mpv_idct_init(s);
- ff_mpv_common_init(s);
+ if ((err = ff_mpv_common_init(s)) < 0)
+ return err;
}
if (s->height != s1->height || s->width != s1->width || s->context_reinit) {
UPDATE_PICTURE(last_picture);
UPDATE_PICTURE(next_picture);
+#define REBASE_PICTURE(pic, new_ctx, old_ctx) \
+ ((pic && pic >= old_ctx->picture && \
+ pic < old_ctx->picture + MAX_PICTURE_COUNT) ? \
+ &new_ctx->picture[pic - old_ctx->picture] : NULL)
+
s->last_picture_ptr = REBASE_PICTURE(s1->last_picture_ptr, s, s1);
s->current_picture_ptr = REBASE_PICTURE(s1->current_picture_ptr, s, s1);
s->next_picture_ptr = REBASE_PICTURE(s1->next_picture_ptr, s, s1);
int i;
er->avctx = s->avctx;
- er->mecc = &s->mecc;
er->mb_index2xy = s->mb_index2xy;
er->mb_num = s->mb_num;
/* convert fourcc to upper case */
s->codec_tag = avpriv_toupper4(s->avctx->codec_tag);
- s->stream_codec_tag = avpriv_toupper4(s->avctx->stream_codec_tag);
-
FF_ALLOCZ_OR_GOTO(s->avctx, s->picture,
MAX_PICTURE_COUNT * sizeof(Picture), fail);
for (i = 0; i < MAX_PICTURE_COUNT; i++) {
* Is used during resolution changes to avoid a full reinitialization of the
* codec.
*/
-static int free_context_frame(MpegEncContext *s)
+static void free_context_frame(MpegEncContext *s)
{
int i, j, k;
av_freep(&s->bits_tab);
s->linesize = s->uvlinesize = 0;
-
- return 0;
}
int ff_mpv_common_frame_size_change(MpegEncContext *s)
} else
free_duplicate_context(s);
- if ((err = free_context_frame(s)) < 0)
- return err;
+ free_context_frame(s);
if (s->picture)
for (i = 0; i < MAX_PICTURE_COUNT; i++) {
s->mb_height = (s->height + 15) / 16;
if ((s->width || s->height) &&
- av_image_check_size(s->width, s->height, 0, s->avctx))
- return AVERROR_INVALIDDATA;
+ (err = av_image_check_size(s->width, s->height, 0, s->avctx)) < 0)
+ goto fail;
if ((err = init_context_frame(s)))
goto fail;
}
for (i = 0; i < nb_slices; i++) {
- if (init_duplicate_context(s->thread_context[i]) < 0)
+ if ((err = init_duplicate_context(s->thread_context[i])) < 0)
goto fail;
s->thread_context[i]->start_mb_y =
(s->mb_height * (i) + nb_slices / 2) / nb_slices;
static inline int pic_is_unused(MpegEncContext *s, Picture *pic)
{
- if (pic->f->buf[0] == NULL)
+ if (!pic->f->buf[0])
return 1;
if (pic->needs_realloc && !(pic->reference & DELAYED_PIC_REF))
return 1;
if (shared) {
for (i = 0; i < MAX_PICTURE_COUNT; i++) {
- if (s->picture[i].f->buf[0] == NULL)
+ if (!s->picture[i].f->buf[0])
return i;
}
} else {
release_unused_pictures(s);
- if (s->current_picture_ptr &&
- s->current_picture_ptr->f->buf[0] == NULL) {
+ if (s->current_picture_ptr && !s->current_picture_ptr->f->buf[0]) {
// we already have a unused image
// (maybe it was set before reading the header)
pic = s->current_picture_ptr;
s->current_picture_ptr ? s->current_picture_ptr->f->data[0] : NULL,
s->pict_type, s->droppable);
- if ((s->last_picture_ptr == NULL ||
- s->last_picture_ptr->f->buf[0] == NULL) &&
+ if ((!s->last_picture_ptr || !s->last_picture_ptr->f->buf[0]) &&
(s->pict_type != AV_PICTURE_TYPE_I ||
s->picture_structure != PICT_FRAME)) {
int h_chroma_shift, v_chroma_shift;
ff_thread_report_progress(&s->last_picture_ptr->tf, INT_MAX, 0);
ff_thread_report_progress(&s->last_picture_ptr->tf, INT_MAX, 1);
}
- if ((s->next_picture_ptr == NULL ||
- s->next_picture_ptr->f->buf[0] == NULL) &&
+ if ((!s->next_picture_ptr || !s->next_picture_ptr->f->buf[0]) &&
s->pict_type == AV_PICTURE_TYPE_B) {
/* Allocate a dummy frame */
i = ff_find_unused_picture(s, 0);
int i;
MpegEncContext *s = avctx->priv_data;
- if(s==NULL || s->picture==NULL)
+ if (!s || !s->picture)
return;
for (i = 0; i < MAX_PICTURE_COUNT; i++)