Commit a479cb8292 for ffmpeg
commit a479cb82921fbb02699ec0538c426de13603784c
Author: Rainbaby <r@bgr.jp>
Date: Fri Aug 28 16:18:08 2026 +0900
avcodec/cavsdec: parse the AVS1-P16 picture header
profile_id 0x48 extends both picture headers (tables 21 and 22). The
marker bit after time_code is pinned so the stream_revision heuristic
cannot misread it.
decode_seq_header() still refuses profile_id 0x48; a later commit opens
the gate, so nothing added here is reachable yet.
Signed-off-by: Rainbaby <r@bgr.jp>
diff --git a/libavcodec/cavs.h b/libavcodec/cavs.h
index 30c51ed6ac..57e619bfd2 100644
--- a/libavcodec/cavs.h
+++ b/libavcodec/cavs.h
@@ -186,6 +186,7 @@ typedef struct AVSContext {
int progressive;
int pic_structure;
int skip_mode_flag; ///< select between skip_count or one skip_flag per MB
+ int aec_enable; ///< the macroblock layer uses AEC (AVS1-P16)
int loop_filter_disable;
int alpha_offset, beta_offset;
int ref_flag;
diff --git a/libavcodec/cavsdec.c b/libavcodec/cavsdec.c
index 490aa3319a..1177530bed 100644
--- a/libavcodec/cavsdec.c
+++ b/libavcodec/cavsdec.c
@@ -1034,6 +1034,8 @@ static int decode_pic(AVSContext *h)
av_frame_unref(h->cur.f);
skip_bits(&h->gb, 16);//bbv_delay
+ if (h->profile == AV_PROFILE_CAVS_BROADCASTING)
+ skip_bits(&h->gb, 8); //marker_bit, bbv_delay_extension (tables 21, 22)
if (h->stc == PIC_PB_START_CODE) {
h->cur.f->pict_type = get_bits(&h->gb, 2) + AV_PICTURE_TYPE_I;
if (h->cur.f->pict_type > AV_PICTURE_TYPE_B) {
@@ -1048,9 +1050,12 @@ static int decode_pic(AVSContext *h)
h->cur.f->pict_type = AV_PICTURE_TYPE_I;
if (get_bits1(&h->gb))
skip_bits(&h->gb, 24);//time_code
- /* old sample clips were all progressive and no low_delay,
- bump stream revision if detected otherwise */
- if (h->low_delay || !(show_bits(&h->gb, 9) & 1))
+ /* a Broadcasting stream always has the marker bit (table 21); old
+ JiZhun sample clips were all progressive and no low_delay, bump
+ stream revision if detected otherwise */
+ if (h->profile == AV_PROFILE_CAVS_BROADCASTING)
+ h->stream_revision = 1;
+ else if (h->low_delay || !(show_bits(&h->gb, 9) & 1))
h->stream_revision = 1;
/* similarly test top_field_first and repeat_first_field */
else if (show_bits(&h->gb, 11) & 3)
@@ -1131,6 +1136,16 @@ static int decode_pic(AVSContext *h)
h->alpha_offset = h->beta_offset = 0;
}
+ /* AWQ parameters and aec_enable end the header (tables 21, 22) */
+ h->aec_enable = 0;
+ if (h->profile == AV_PROFILE_CAVS_BROADCASTING) {
+ if (get_bits1(&h->gb)) { //weighting_quant_flag
+ avpriv_request_sample(h->avctx, "Adaptive weighted quantization");
+ return AVERROR_PATCHWELCOME;
+ }
+ h->aec_enable = get_bits1(&h->gb);
+ }
+
ret = 0;
h->pic_data_end = 0;
if (h->cur.f->pict_type == AV_PICTURE_TYPE_I) {