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
36 int frame_width;36 int frame_width;
37 int frame_height;37 int frame_height;
38 38
39 uint8_t chroma_format_idc;
40 uint8_t bit_depth_minus8;39 uint8_t bit_depth_minus8;
41
42 enum AVPixelFormat pixel_format;
43} APVHeaderInfo;40} APVHeaderInfo;
44 41
45static const enum AVPixelFormat apv_format_table[5][5] = {42static int apv_extract_header_info(GetByteContext *gbc)
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
53static int apv_extract_header_info(APVHeaderInfo *info,
54 GetByteContext *gbc)
55{43{
56 int zero, byte, bit_depth_index;44 APVHeaderInfo header, *info = &header;
45 int zero, byte;
57 46
58 info->pbu_type = bytestream2_get_byte(gbc);47 info->pbu_type = bytestream2_get_byte(gbc);
59 info->group_id = bytestream2_get_be16(gbc);48 info->group_id = bytestream2_get_be16(gbc);
@@ -81,7 +70,6 @@ static int apv_extract_header_info(APVHeaderInfo *info, · 21 unmodified lines
81 return AVERROR_INVALIDDATA;70 return AVERROR_INVALIDDATA;
82 71
83 byte = bytestream2_get_byte(gbc);72 byte = bytestream2_get_byte(gbc);
84 info->chroma_format_idc = byte >> 4;
85 info->bit_depth_minus8 = byte & 0xf;73 info->bit_depth_minus8 = byte & 0xf;
86 74
87 if (info->bit_depth_minus8 > 8) {75 if (info->bit_depth_minus8 > 8) {
@@ -91,18 +79,6 @@ static int apv_extract_header_info(APVHeaderInfo *info, · 3 unmodified lines
91 // Odd bit depths are technically valid but not useful here.79 // Odd bit depths are technically valid but not useful here.
92 return AVERROR_INVALIDDATA;80 return AVERROR_INVALIDDATA;
93 }81 }
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 }
106 82
107 // Ignore capture_time_distance.83 // Ignore capture_time_distance.
108 bytestream2_skip(gbc, 1);84 bytestream2_skip(gbc, 1);
@@ -117,7 +93,6 @@ static int apv_extract_header_info(APVHeaderInfo *info, · 8 unmodified lines
117static int apv_probe(const AVProbeData *p)93static int apv_probe(const AVProbeData *p)
118{94{
119 GetByteContext gbc;95 GetByteContext gbc;
120 APVHeaderInfo header;
121 uint32_t au_size, signature, pbu_size;96 uint32_t au_size, signature, pbu_size;
122 int err;97 int err;
123 98
@@ -144,7 +119,7 @@ static int apv_probe(const AVProbeData *p) · 20 unmodified lines
144 return 0;119 return 0;
145 }120 }
146 121
147 err = apv_extract_header_info(&header, &gbc);122 err = apv_extract_header_info(&gbc);
148 if (err < 0) {123 if (err < 0) {
149 // Header does not look like APV.124 // Header does not look like APV.
150 return 0;125 return 0;
@@ -156,8 +131,7 @@ static int apv_read_header(AVFormatContext *s) · 5 unmodified lines
156{131{
157 AVStream *st;132 AVStream *st;
158 GetByteContext gbc;133 GetByteContext gbc;
159 APVHeaderInfo header;134 uint8_t buffer[12];
160 uint8_t buffer[28];
161 uint32_t au_size, signature, pbu_size;135 uint32_t au_size, signature, pbu_size;
162 int err, size;136 int err, size;
163 137
@@ -186,22 +160,14 @@ static int apv_read_header(AVFormatContext *s) · 22 unmodified lines
186 return AVERROR_INVALIDDATA;160 return AVERROR_INVALIDDATA;
187 }161 }
188 162
189 err = apv_extract_header_info(&header, &gbc);
190 if (err < 0)
191 return err;
192
193 st = avformat_new_stream(s, NULL);163 st = avformat_new_stream(s, NULL);
194 if (!st)164 if (!st)
195 return AVERROR(ENOMEM);165 return AVERROR(ENOMEM);
196 166
197 st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;167 st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
198 st->codecpar->codec_id = AV_CODEC_ID_APV;168 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;
204 169
170 ffstream(st)->need_parsing = AVSTREAM_PARSE_HEADERS;
205 st->avg_frame_rate = (AVRational){ 30, 1 };171 st->avg_frame_rate = (AVRational){ 30, 1 };
206 avpriv_set_pts_info(st, 64, 1, 30);172 avpriv_set_pts_info(st, 64, 1, 30);
207 173

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