Skip to content

[ENHANCEMENT] Handle idr_pic_id in AVC slice header parsing #1895

@Harshdhall01

Description

@Harshdhall01

Description:

Found a TODO in the AVC slice header parsing that suggests incomplete handling of IDR picture IDs:

Location:src/lib_ccx/avc_functions.c:998

Current code:

if (nal_unit_type == 5)
{
    tmp = read_exp_golomb_unsigned(&q1);
    dvprint("idr_pic_id=            % 4lld (%#llX)\n", tmp, tmp);
    // TODO
}

Issue:
The IDR (Instantaneous Decoder Refresh) picture ID is:

  • ✅ Successfully read from the bitstream
  • ✅ Printed for debugging (dvprint)
  • ❌ Not stored in any context structure
  • ❌ Not used for any further processing

Potential improvements:

  1. Store the value in an appropriate context structure (e.g., dec_ctx->avc_ctx->idr_pic_id)
  2. Use the value for frame identification or ordering if needed
  3. Document why it's read but not used (if intentional)

Questions for maintainers:

  1. Should idr_pic_id be stored in the AVC context?
  2. Is this value needed for caption extraction, or is reading it sufficient?
  3. Are there cases where this ID would be useful for timing or frame ordering?

Research:
According to H.264 spec, idr_pic_id identifies IDR pictures and can range from 0-65535. It's used to identify different IDR pictures when multiple occur in sequence.

Proposed solution:

  1. Add idr_pic_id field to the appropriate context structure
  2. Store the value when read
  3. Add comment explaining its purpose
  4. (Optional) Expose it in debug output or logging

Background:
Working toward GSoC 2026 with CCExtractor. First PR (#1889) merged. Focusing on core video processing and subtitle extraction for the CCExtractor 1.00 release.

Would love to implement this if you can guide me on whether/how the ID should be used!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions