lavc/av1_parser: Extract SAR from render_size
Extract the Sample Aspect Ratio (SAR) from render_width_minus_1 and render_height_minus_1 in the sequence header. The AV1 specification defines the render dimensions, which can be used in conjunction with the coded dimensions to determine the pixel aspect ratio. This ensures consistent aspect ratio handling for AV1 streams encapsulated in containers like MP4 or MKV, as observed in the updated FATE tests where SAR changes from 0/1 to 1/1. Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
This commit is contained in:
@@ -134,6 +134,13 @@ static int av1_parser_parse(AVCodecParserContext *ctx,
|
||||
break;
|
||||
}
|
||||
ctx->picture_structure = AV_PICTURE_STRUCTURE_FRAME;
|
||||
|
||||
/* Extract SAR from render_height_minus_1 & render_width_minus_1 */
|
||||
av_reduce(&avctx->sample_aspect_ratio.num,
|
||||
&avctx->sample_aspect_ratio.den,
|
||||
(int64_t)ctx->height * (frame->render_width_minus_1 + 1),
|
||||
(int64_t)ctx->width * (frame->render_height_minus_1 + 1),
|
||||
INT_MAX);
|
||||
}
|
||||
|
||||
switch (av1->bit_depth) {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#media_type 0: video
|
||||
#codec_id 0: av1
|
||||
#dimensions 0: 300x300
|
||||
#sar 0: 0/1
|
||||
#sar 0: 1/1
|
||||
0, 0, 0, 48000, 12691, 0xf0adcc79
|
||||
0, 48000, 48000, 48000, 4975, 0x1742a45f, F=0x0
|
||||
0, 96000, 96000, 48000, 928, 0x7408be1a, F=0x0
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#media_type 0: video
|
||||
#codec_id 0: av1
|
||||
#dimensions 0: 320x176
|
||||
#sar 0: 0/1
|
||||
#sar 0: 1/1
|
||||
0, 0, 0, 41, 4718, 0xc4d912ec
|
||||
0, 42, 42, 41, 5109, 0xc065dd7d, F=0x0
|
||||
0, 83, 83, 41, 192, 0x160c5335, F=0x0
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
#media_type 4: video
|
||||
#codec_id 4: av1
|
||||
#dimensions 4: 1920x1080
|
||||
#sar 4: 0/1
|
||||
#sar 4: 1/1
|
||||
#tb 5: 1/1000
|
||||
#media_type 5: audio
|
||||
#codec_id 5: flac
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
d875b42964dd55c8cea2e2752379d327 *tests/data/lavf-fate/lavf.av1.mkv
|
||||
55660 tests/data/lavf-fate/lavf.av1.mkv
|
||||
ba198efa114b4db3c9f772728f84978b *tests/data/lavf-fate/lavf.av1.mkv
|
||||
55656 tests/data/lavf-fate/lavf.av1.mkv
|
||||
tests/data/lavf-fate/lavf.av1.mkv CRC=0x7c27cc15
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
194cd796f3d28a890b516b2507f57180 *tests/data/lavf-fate/lavf.av1.mp4
|
||||
55960 tests/data/lavf-fate/lavf.av1.mp4
|
||||
d6afef355cf1bcf1a71b9cfb98c32fba *tests/data/lavf-fate/lavf.av1.mp4
|
||||
55976 tests/data/lavf-fate/lavf.av1.mp4
|
||||
tests/data/lavf-fate/lavf.av1.mp4 CRC=0x7c27cc15
|
||||
|
||||
Reference in New Issue
Block a user