History

avformat/apvdec: don't fill container level fields with codec level info

This is a raw demuxer, it should not read codec level information and export it as container level information. The generic demux code will use the recently introduced parser to take care of that.

James Almer committed 1 year ago

Commit 33d0d1c1 parent c4ea4ab2 files · +7 −40Browse files

Showing the changes to libavformat (1 of 2 files). Show all

Unified · Split

libavformat/apvdec.c+6−40
@@ -36,24 +36,13 @@ typedef struct APVHeaderInfo { · 35 unmodified lines
3636 int frame_width;
3737 int frame_height;
3838
39− uint8_t chroma_format_idc;
4039 uint8_t bit_depth_minus8;
41−
42− enum AVPixelFormat pixel_format;
4340 } APVHeaderInfo;
4441
45−static const enum AVPixelFormat apv_format_table[5][5] = {
46− { AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY10, AV_PIX_FMT_GRAY12, AV_PIX_FMT_GRAY14, AV_PIX_FMT_GRAY16 },
47− { 0 }, // 4:2:0 is not valid.
48− { AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV422P12, AV_PIX_FMT_GRAY14, AV_PIX_FMT_YUV422P16 },
49− { AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUV444P10, AV_PIX_FMT_YUV444P12, AV_PIX_FMT_GRAY14, AV_PIX_FMT_YUV444P16 },
50− { AV_PIX_FMT_YUVA444P, AV_PIX_FMT_YUVA444P10, AV_PIX_FMT_YUVA444P12, AV_PIX_FMT_GRAY14, AV_PIX_FMT_YUVA444P16 },
51−};
52−
53−static int apv_extract_header_info(APVHeaderInfo *info,
54− GetByteContext *gbc)
42+static int apv_extract_header_info(GetByteContext *gbc)
5543 {
56− int zero, byte, bit_depth_index;
44+ APVHeaderInfo header, *info = &header;
45+ int zero, byte;
5746
5847 info->pbu_type = bytestream2_get_byte(gbc);
5948 info->group_id = bytestream2_get_be16(gbc);
@@ -81,7 +70,6 @@ static int apv_extract_header_info(APVHeaderInfo *info, · 21 unmodified lines
8170 return AVERROR_INVALIDDATA;
8271
8372 byte = bytestream2_get_byte(gbc);
84− info->chroma_format_idc = byte >> 4;
8573 info->bit_depth_minus8 = byte & 0xf;
8674
8775 if (info->bit_depth_minus8 > 8) {
@@ -91,18 +79,6 @@ static int apv_extract_header_info(APVHeaderInfo *info, · 3 unmodified lines
9179 // Odd bit depths are technically valid but not useful here.
9280 return AVERROR_INVALIDDATA;
9381 }
94− bit_depth_index = info->bit_depth_minus8 / 2;
95−
96− switch (info->chroma_format_idc) {
97− case APV_CHROMA_FORMAT_400:
98− case APV_CHROMA_FORMAT_422:
99− case APV_CHROMA_FORMAT_444:
100− case APV_CHROMA_FORMAT_4444:
101− info->pixel_format = apv_format_table[info->chroma_format_idc][bit_depth_index];
102− break;
103− default:
104− return AVERROR_INVALIDDATA;
105− }
10682
10783 // Ignore capture_time_distance.
10884 bytestream2_skip(gbc, 1);
@@ -117,7 +93,6 @@ static int apv_extract_header_info(APVHeaderInfo *info, · 8 unmodified lines
11793 static int apv_probe(const AVProbeData *p)
11894 {
11995 GetByteContext gbc;
120− APVHeaderInfo header;
12196 uint32_t au_size, signature, pbu_size;
12297 int err;
12398
@@ -144,7 +119,7 @@ static int apv_probe(const AVProbeData *p) · 20 unmodified lines
144119 return 0;
145120 }
146121
147− err = apv_extract_header_info(&header, &gbc);
122+ err = apv_extract_header_info(&gbc);
148123 if (err < 0) {
149124 // Header does not look like APV.
150125 return 0;
@@ -156,8 +131,7 @@ static int apv_read_header(AVFormatContext *s) · 5 unmodified lines
156131 {
157132 AVStream *st;
158133 GetByteContext gbc;
159− APVHeaderInfo header;
160− uint8_t buffer[28];
134+ uint8_t buffer[12];
161135 uint32_t au_size, signature, pbu_size;
162136 int err, size;
163137
@@ -186,22 +160,14 @@ static int apv_read_header(AVFormatContext *s) · 22 unmodified lines
186160 return AVERROR_INVALIDDATA;
187161 }
188162
189− err = apv_extract_header_info(&header, &gbc);
190− if (err < 0)
191− return err;
192−
193163 st = avformat_new_stream(s, NULL);
194164 if (!st)
195165 return AVERROR(ENOMEM);
196166
197167 st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
198168 st->codecpar->codec_id = AV_CODEC_ID_APV;
199− st->codecpar->format = header.pixel_format;
200− st->codecpar->profile = header.profile_idc;
201− st->codecpar->level = header.level_idc;
202− st->codecpar->width = header.frame_width;
203− st->codecpar->height = header.frame_height;
204169
170+ ffstream(st)->need_parsing = AVSTREAM_PARSE_HEADERS;
205171 st->avg_frame_rate = (AVRational){ 30, 1 };
206172 avpriv_set_pts_info(st, 64, 1, 30);
207173

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