}
}
- static int alloc_picture_tables(MpegEncContext *s, Picture *pic)
-static int alloc_picture_tables(Picture *pic, int encoding, int out_format,
- int mb_stride, int mb_height, int b8_stride)
++static int alloc_picture_tables(AVCodecContext *avctx, Picture *pic, int encoding, int out_format,
++ int mb_stride, int mb_width, int mb_height, int b8_stride)
{
- const int big_mb_num = s->mb_stride * (s->mb_height + 1) + 1;
- const int mb_array_size = s->mb_stride * s->mb_height;
- const int b8_array_size = s->b8_stride * s->mb_height * 2;
+ const int big_mb_num = mb_stride * (mb_height + 1) + 1;
+ const int mb_array_size = mb_stride * mb_height;
+ const int b8_array_size = b8_stride * mb_height * 2;
int i;
return AVERROR(ENOMEM);
}
- if (s->out_format == FMT_H263 || s->encoding || s->avctx->debug_mv ||
- (s->avctx->flags2 & CODEC_FLAG2_EXPORT_MVS)) {
- if (out_format == FMT_H263 || encoding) {
++ if (out_format == FMT_H263 || encoding || avctx->debug_mv ||
++ (avctx->flags2 & CODEC_FLAG2_EXPORT_MVS)) {
int mv_size = 2 * (b8_array_size + 4) * sizeof(int16_t);
int ref_index_size = 4 * mb_array_size;
}
}
- pic->alloc_mb_width = s->mb_width;
- pic->alloc_mb_height = s->mb_height;
++ pic->alloc_mb_width = mb_width;
++ pic->alloc_mb_height = mb_height;
+
return 0;
}
return 0;
}
- s->mb_stride, s->mb_height, s->b8_stride,
+ static int alloc_picture(MpegEncContext *s, Picture *pic, int shared)
+ {
+ return ff_alloc_picture(s->avctx, pic, &s->me, &s->sc, shared, 0,
+ s->chroma_x_shift, s->chroma_y_shift, s->out_format,
++ s->mb_stride, s->mb_width, s->mb_height, s->b8_stride,
+ &s->linesize, &s->uvlinesize);
+ }
+
/**
* Allocate a Picture.
* The pixels are allocated/set by calling get_buffer() if shared = 0
*/
- int ff_alloc_picture(MpegEncContext *s, Picture *pic, int shared)
+ int ff_alloc_picture(AVCodecContext *avctx, Picture *pic, MotionEstContext *me,
+ ScratchpadContext *sc, int shared, int encoding,
+ int chroma_x_shift, int chroma_y_shift, int out_format,
- int mb_stride, int mb_height, int b8_stride,
++ int mb_stride, int mb_width, int mb_height, int b8_stride,
+ ptrdiff_t *linesize, ptrdiff_t *uvlinesize)
{
int i, ret;
- if ( pic->alloc_mb_width != s->mb_width
- || pic->alloc_mb_height != s->mb_height)
+ if (pic->qscale_table_buf)
++ if ( pic->alloc_mb_width != mb_width
++ || pic->alloc_mb_height != mb_height)
+ ff_free_picture_tables(pic);
+
if (shared) {
- assert(pic->f->data[0]);
+ av_assert0(pic->f->data[0]);
pic->shared = 1;
} else {
- assert(!pic->f->buf[0]);
+ av_assert0(!pic->f->buf[0]);
-
- if (alloc_frame_buffer(s, pic) < 0)
+ if (alloc_frame_buffer(avctx, pic, me, sc,
+ chroma_x_shift, chroma_y_shift,
+ *linesize, *uvlinesize) < 0)
return -1;
- s->linesize = pic->f->linesize[0];
- s->uvlinesize = pic->f->linesize[1];
+ *linesize = pic->f->linesize[0];
+ *uvlinesize = pic->f->linesize[1];
}
if (!pic->qscale_table_buf)
- ret = alloc_picture_tables(s, pic);
- ret = alloc_picture_tables(pic, encoding, out_format,
- mb_stride, mb_height, b8_stride);
++ ret = alloc_picture_tables(avctx, pic, encoding, out_format,
++ mb_stride, mb_width, mb_height, b8_stride);
else
ret = make_tables_writable(pic);
if (ret < 0)
s->last_picture_ptr = &s->picture[i];
s->last_picture_ptr->reference = 3;
- s->last_picture_ptr->f->pict_type = AV_PICTURE_TYPE_I;
+ s->last_picture_ptr->f->key_frame = 0;
+ s->last_picture_ptr->f->pict_type = AV_PICTURE_TYPE_P;
- if (ff_alloc_picture(s, s->last_picture_ptr, 0) < 0) {
+ if (alloc_picture(s, s->last_picture_ptr, 0) < 0) {
s->last_picture_ptr = NULL;
return -1;
}
s->next_picture_ptr = &s->picture[i];
s->next_picture_ptr->reference = 3;
- s->next_picture_ptr->f->pict_type = AV_PICTURE_TYPE_I;
+ s->next_picture_ptr->f->key_frame = 0;
+ s->next_picture_ptr->f->pict_type = AV_PICTURE_TYPE_P;
- if (ff_alloc_picture(s, s->next_picture_ptr, 0) < 0) {
+ if (alloc_picture(s, s->next_picture_ptr, 0) < 0) {
s->next_picture_ptr = NULL;
return -1;
}