Use frames directly and add a NULL check.
Also drop ff_draw_horiz_band() because it's not used anywhere.
---
libavcodec/mpegvideo.c | 57 +++++++++++++++++++++++++-------------------------
libavcodec/mpegvideo.h | 5 +----
2 files changed, 29 insertions(+), 33 deletions(-)
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 73778f5..be996ea 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -2313,41 +2313,47 @@ void ff_MPV_decode_mb(MpegEncContext *s, int16_t
block[12][64]){
/**
* @param h is the normal height, this will be reduced automatically if needed
for the last row
*/
-void ff_draw_horiz_band(AVCodecContext *avctx, Picture *cur,
- Picture *last, int y, int h, int picture_structure,
- int first_field, int low_delay)
+void ff_mpeg_draw_horiz_band(MpegEncContext *s, int y, int height)
{
- const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
- int vshift = desc->log2_chroma_h;
- const int field_pic = picture_structure != PICT_FRAME;
- if(field_pic){
- h <<= 1;
+ const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(s->avctx->pix_fmt);
+ const int field_pic = s->picture_structure != PICT_FRAME;
+ int vshift;
+
+ if (!desc)
+ return;
+
+ vshift = desc->log2_chroma_h;
+
+ if (field_pic) {
+ height <<= 1;
y <<= 1;
}
- h = FFMIN(h, avctx->height - y);
+ height = FFMIN(height, s->avctx->height - y);
- if(field_pic && first_field &&
!(avctx->slice_flags&SLICE_FLAG_ALLOW_FIELD)) return;
+ if (field_pic && s->first_field &&
+ !(s->avctx->slice_flags & SLICE_FLAG_ALLOW_FIELD))
+ return;
- if (avctx->draw_horiz_band) {
+ if (s->avctx->draw_horiz_band) {
+ AVFrame *cur = &s->current_picture.f;
AVFrame *src;
int offset[AV_NUM_DATA_POINTERS];
int i;
- if(cur->f.pict_type == AV_PICTURE_TYPE_B || low_delay ||
- (avctx->slice_flags & SLICE_FLAG_CODED_ORDER))
- src = &cur->f;
- else if (last)
- src = &last->f;
+ if(cur->pict_type == AV_PICTURE_TYPE_B ||
+ s->low_delay || (s->avctx->slice_flags & SLICE_FLAG_CODED_ORDER))
+ src = cur;
+ else if (s->last_picture.f.data[0])
+ src = &s->last_picture.f;
else
return;
- if (cur->f.pict_type == AV_PICTURE_TYPE_B &&
- picture_structure == PICT_FRAME &&
- avctx->codec_id != AV_CODEC_ID_SVQ3) {
+ if (cur->pict_type == AV_PICTURE_TYPE_B &&
+ s->picture_structure == PICT_FRAME) {
for (i = 0; i < AV_NUM_DATA_POINTERS; i++)
offset[i] = 0;
- }else{
+ } else {
offset[0]= y * src->linesize[0];
offset[1]=
offset[2]= (y >> vshift) * src->linesize[1];
@@ -2357,18 +2363,11 @@ void ff_draw_horiz_band(AVCodecContext *avctx, Picture
*cur,
emms_c();
- avctx->draw_horiz_band(avctx, src, offset,
- y, picture_structure, h);
+ s->avctx->draw_horiz_band(s->avctx, src, offset,
+ y, s->picture_structure, height);
}
}
-void ff_mpeg_draw_horiz_band(MpegEncContext *s, int y, int h)
-{
- ff_draw_horiz_band(s->avctx, &s->current_picture,
- &s->last_picture, y, h, s->picture_structure,
- s->first_field, s->low_delay);
-}
-
void ff_init_block_index(MpegEncContext *s){ //FIXME maybe rename
const int linesize = s->current_picture.f.linesize[0]; //not s->linesize
as this would be wrong for field pics
const int uvlinesize = s->current_picture.f.linesize[1];
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index f888700..35db031 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -784,10 +784,7 @@ void ff_MPV_common_init_x86(MpegEncContext *s);
void ff_MPV_common_init_arm(MpegEncContext *s);
void ff_MPV_common_init_ppc(MpegEncContext *s);
void ff_clean_intra_table_entries(MpegEncContext *s);
-void ff_draw_horiz_band(AVCodecContext *avctx, Picture *cur, Picture *last,
- int y, int h, int picture_structure, int first_field,
- int low_delay);
-void ff_mpeg_draw_horiz_band(MpegEncContext *s, int y, int h);
+void ff_mpeg_draw_horiz_band(MpegEncContext *s, int y, int height);
void ff_mpeg_flush(AVCodecContext *avctx);
void ff_print_debug_info(MpegEncContext *s, Picture *p);
void ff_write_quant_matrix(PutBitContext *pb, uint16_t *matrix);
--
1.8.3.4 (Apple Git-47)
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel