[FFmpeg-devel] [PATCH] Macroblocks modes extraction
James Almer
jamrial at gmail.com
Fri Jul 4 15:36:08 EEST 2025
On 7/2/2025 7:57 AM, Timothee wrote:
> Hello,
>
> I am working on a modification toextract per-macroblock prediction modes
> (H.264 for now). The goal is to make this information available to
> vf_codecview and print it in a log file (for now).
>
> This are what I have added:
>
> 1.
>
> A new H264MBInfostruct holding the prediction modes.
Isn't this what libavutil/video_enc_params.h is for? Or if needed, what
it could be extended to handle?
>
> 2.
>
> An AVBufferRef *mb_info_refis added to the H264Picturestruct to
> store this data for each picture.
>
> 3.
>
> This buffer is allocated with av_buffer_allocz()in
> alloc_picture()and its reference is released with
> av_buffer_unref()in ff_h264_unref_picture().
>
> 4.
>
> A new function, ff_h264_collect_mb_info(), is called after
> macroblock decoding to populate the buffer.
>
> 5.
>
> In output_frame(), a new side data (AV_FRAME_DATA_H264_MB_INFO)
> buffer is allocated, and the contents of srcp->mb_info_ref->dataare
> copied into it.
>
> 6. A new function to log the result in vf_codecview.c
>
> This implementation results in a segmentation fault. I guess it is a
> race condition, but I am struggling to fix it.
>
> The patch provided should result in the same error when running `./
> ffmpeg -loglevel debug -i input.mp4 -vf codecview=show_modes=1 -f null -`
>
> Are side data the right thing to use in this context ? Is there a better
> approach to do it ?
>
> I am new to FFmpeg and, in general, to large open-source projects, but I
> am willing to learn so please do not hesitate to correct me.
>
> Thank you for your guidance.
>
> Timothée
>
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature.asc
Type: application/pgp-signature
Size: 495 bytes
Desc: OpenPGP digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20250704/67bfc53f/attachment.sig>
More information about the ffmpeg-devel
mailing list