[Libav-user] extract min/max/avg QP-values per frame

siriannalisa siriannalisa at gmail.com
Wed May 6 10:56:15 CEST 2015

The quantization parameter (QP) is signaled on several levels in a
H.264 stream. Absolute QP pr stream in the PPS, slize_qp_delta per
image in slice_header and delta per macroblock.

>From the standard:

pic_init_qp_minus26 specifies the initial value minus 26 of SliceQPY
for each slice. The initial value is modified at the
slice layer when a non-zero value of slice_qp_delta is decoded, and is
modified further when a non-zero value of
mb_qp_delta is decoded at the macroblock layer. The value of
pic_init_qp_minus26 shall be in the range of
−(26 + QpBdOffsetY ) to +25, inclusive.

mb_qp_delta can change the value of QPY in the macroblock layer. The
decoded value of mb_qp_delta shall be in the
range of −( 26 + QpBdOffsetY / 2) to +( 25 + QpBdOffsetY / 2 ),
inclusive. mb_qp_delta shall be inferred to be equal to 0
when it is not present for any macroblock (including P_Skip and B_Skip
macroblock types).


The QP value for each MB in a frame appears to be available in
libavcodec/h264.c:1836 in variable

But I fail to find a way to access that data from my function! (I can
run ffmpeg single treaded, and export a global variable containing the
content of qscale_table but that is not what I want)


On Tue, May 5, 2015 at 10:13 PM, Marcus Johnson
<bumblebritches57 at gmail.com> wrote:
> I haven't studied the H.264 bitstream specs too much, but do they even
> include a metadata entry for storing the quality at all?
> if not you'd have to guesstimate based on the actual data but that would be
> hard as hell... I honestly doubt it's even possible.
> Nice idea though.
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user

More information about the Libav-user mailing list