This allows the compiler to remove the implicit "Do I need to output
the PutBitContext buffer here?" checks.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
The earlier code allowed callers to use arbitrary values as
symbols_size as long as no symbols were present.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This turned out to be very beneficial: For GCC 13, the codesize
of ac3_output_frame_header went down from 4522B to 1247B and
from 10762B to 9298B for eac3_output_frame_header. For Clang 17,
the numbers went down from 3923B to 2477B and from 8338B to 6548B
(always with -O3).
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This will allow the compiler to optimize the "is the cache full?"
branches away from some put_bits().
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Fixes a Clang warning when asserts are disabled:
"variable 'quant' is used uninitialized whenever switch default is taken
[-Wsometimes-uninitialized]"
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Useful to let the compiler and static analyzers know that
something is unreachable without adding an av_assert
(which would be either dead for the compiler or add runtime
overhead) for this.
The implementation used here enforces the use of a message
to provide a reason why a particular code is supposed to be
unreachable.
Reviewed-by: Ramiro Polla <ramiro.polla@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Use av_frame_move_ref() instead of av_frame_ref().
This allows to remove the separate variable for whether
we have already returned the delayed last pic. It also
makes stream looping work when looping multiple times;
previously the delayed pic was only output the first time,
because last_frame_output was never reset.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
The file has buggy timestamps (it uses B-frames, yet pts==dts)
and therefore the last frame is currently discarded by FFmpeg cli.
Using -fps_mode passthrough avoids this and provides coverage
of the SVQ3 draining logic.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Reduces indentation and avoids an extra variable for whether
a sequence header has been found.
It also fixes potential undefined behaviour:
NULL + 0 is undefined and happens when no extradata is available.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This is a 16bit field in the spec, so using a single
put_bits() to write it is more natural.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
These have been added in 29644cb504
in 2007 at a time when the MPEG-1/2 parser just set
the AVCodecContext's dimensions when encountering a sequence header,
so that the checks for the coded dimensions didn't trigger.
Yet this is no more and so we can simply remove these redundant checks.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Otherwise the MpegEncContext would be unnecessarily reinitialized
once (this does not affect the output for an intra-only variant
like VCR2) in mpeg_decode_postinit().
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
It is its only user. Also make it static and call it
before ff_mpeg_draw_horiz_band().
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>