History

avcodec/mpegutils: Fix ff_draw_horiz_band()

Broken in 5ecf5b93dda9d0c69875b80d28929f0d97dd7d06. More precisely, 3994623df2efd2749631c3492184dd8d4ffa9d1b changed the precursor of ff_mpv_reconstruct_mb() to always decode to the first row of macroblocks for B pictures when a draw_horiz_band callback is set and to (they are exported to the caller via said callback and each row overwrites the previously decoded row; this was probably intended as a cache-optimization). This first macroblock row was used as source for the draw_horiz_band callback. This of course means that the ordinary output B-frame was not decoded correctly at all. Therefore the first aforementioned commit removed this special handling of draw_horiz_band; yet it did not remove the special handling for B-frames in ff_draw_horiz_band(), which broke draw_horiz_band for B-frames. This commit fixes this. (Actually, draw_horiz_band was already broken before 5ecf5b93dda9d0c69875b80d28929f0d97dd7d06 when using slice-threading: All slice-threads would write to the first row of macroblocks for B-frames, leading to data races. It seems no one has ever complained about this, just as no one has ever complained about the breakage caused by 5ecf5b93dda9d0c69875b80d28929f0d97dd7d06. Probably no one uses draw_horiz_band.)

Andreas Rheinhardt committed 2 years ago

Commit c28e5531 parent f8b8f161 file · +8 −15Browse files

Showing the changes to libavcodec (1 of 1 file). Show all

Unified · Split

libavcodec/mpegutils.c+8−15
@@ -57,6 +57,7 @@ void ff_draw_horiz_band(AVCodecContext *avctx, · 56 unmodified lines
57 int first_field, int low_delay)57 int first_field, int low_delay)
58{58{
59 const int field_pic = picture_structure != PICT_FRAME;59 const int field_pic = picture_structure != PICT_FRAME;
60 const AVPixFmtDescriptor *desc;
60 const AVFrame *src;61 const AVFrame *src;
61 int offset[AV_NUM_DATA_POINTERS];62 int offset[AV_NUM_DATA_POINTERS];
62 63
@@ -82,21 +83,13 @@ void ff_draw_horiz_band(AVCodecContext *avctx, · 19 unmodified lines
82 else83 else
83 return;84 return;
84 85
85 if (cur->pict_type == AV_PICTURE_TYPE_B &&86 desc = av_pix_fmt_desc_get(avctx->pix_fmt);
86 picture_structure == PICT_FRAME &&87
87 avctx->codec_id != AV_CODEC_ID_SVQ3) {88 offset[0] = y * src->linesize[0];
88 for (int i = 0; i < AV_NUM_DATA_POINTERS; i++)89 offset[1] =
89 offset[i] = 0;90 offset[2] = (y >> desc->log2_chroma_h) * src->linesize[1];
90 } else {91 for (int i = 3; i < AV_NUM_DATA_POINTERS; i++)
91 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);92 offset[i] = 0;
92 int vshift = desc->log2_chroma_h;
93
94 offset[0] = y * src->linesize[0];
95 offset[1] =
96 offset[2] = (y >> vshift) * src->linesize[1];
97 for (int i = 3; i < AV_NUM_DATA_POINTERS; i++)
98 offset[i] = 0;
99 }
100 93
101 emms_c();94 emms_c();
102 95

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t