avcodec/mpegutils: Return early in ff_draw_horiz_band()

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt 2022-10-16 22:15:05 +02:00
parent 85f02c300f
commit 678f1b1cf4
1 changed files with 10 additions and 8 deletions

View File

@ -53,9 +53,14 @@ void ff_draw_horiz_band(AVCodecContext *avctx,
int y, int h, int picture_structure, int y, int h, int picture_structure,
int first_field, int low_delay) int first_field, int low_delay)
{ {
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; const int field_pic = picture_structure != PICT_FRAME;
const AVFrame *src;
int offset[AV_NUM_DATA_POINTERS];
int i;
if (!avctx->draw_horiz_band)
return;
if (field_pic) { if (field_pic) {
h <<= 1; h <<= 1;
y <<= 1; y <<= 1;
@ -67,11 +72,6 @@ void ff_draw_horiz_band(AVCodecContext *avctx,
!(avctx->slice_flags & SLICE_FLAG_ALLOW_FIELD)) !(avctx->slice_flags & SLICE_FLAG_ALLOW_FIELD))
return; return;
if (avctx->draw_horiz_band) {
const AVFrame *src;
int offset[AV_NUM_DATA_POINTERS];
int i;
if (cur->pict_type == AV_PICTURE_TYPE_B || low_delay || if (cur->pict_type == AV_PICTURE_TYPE_B || low_delay ||
(avctx->slice_flags & SLICE_FLAG_CODED_ORDER)) (avctx->slice_flags & SLICE_FLAG_CODED_ORDER))
src = cur; src = cur;
@ -86,6 +86,9 @@ void ff_draw_horiz_band(AVCodecContext *avctx,
for (i = 0; i < AV_NUM_DATA_POINTERS; i++) for (i = 0; i < AV_NUM_DATA_POINTERS; i++)
offset[i] = 0; offset[i] = 0;
} else { } else {
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
int vshift = desc->log2_chroma_h;
offset[0]= y * src->linesize[0]; offset[0]= y * src->linesize[0];
offset[1]= offset[1]=
offset[2]= (y >> vshift) * src->linesize[1]; offset[2]= (y >> vshift) * src->linesize[1];
@ -97,7 +100,6 @@ void ff_draw_horiz_band(AVCodecContext *avctx,
avctx->draw_horiz_band(avctx, src, offset, avctx->draw_horiz_band(avctx, src, offset,
y, picture_structure, h); y, picture_structure, h);
}
} }
static char get_type_mv_char(int mb_type) static char get_type_mv_char(int mb_type)