1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-07 11:13:41 +02:00
Commit Graph

115883 Commits

Author SHA1 Message Date
Andreas Rheinhardt
bbe10bcae8 avcodec/mpeg12dec: Remove write-only assignment
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-12 11:43:59 +02:00
Andreas Rheinhardt
2f22fd7ec1 avcodec/mpeg12dec: Only initialize IDCT for IPU
This is all that is used. This is in preparation for further
commits that will extend ff_mpv_decode_init() in a way
that will make it possible to fail and require cleanup.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-12 11:43:48 +02:00
Andreas Rheinhardt
183a67580b avcodec/mpeg12dec: Don't initialize inter tables for IPU
IPU is intra-only.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-12 11:43:30 +02:00
Andreas Rheinhardt
dceb73a22d avcodec/mpegvideo_enc: Reindentation
Also try to use loop-scope for iterators.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-12 11:43:22 +02:00
Andreas Rheinhardt
b64dfe2bd1 avcodec/mpegvideo_enc: Return early when getting length of B frame chain
Possible now that this is a function of its own.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-12 11:43:14 +02:00
Andreas Rheinhardt
17b5fc2e51 avcodec/mpegvideo_enc: Factor setting length of B frame chain out
It already avoids a goto and will be useful in the future
to be able to specify each functions tasks and obligations.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-12 11:42:59 +02:00
Andreas Rheinhardt
17501b2267 avcodec/error_resilience: Deduplicate cleanup code
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-12 11:42:24 +02:00
Andreas Rheinhardt
fe6037fd04 avcodec/mpegpicture: Split MPVPicture into WorkPicture and ordinary Pic
There are two types of MPVPictures: Three (cur_pic, last_pic, next_pic)
that are directly part of MpegEncContext and an array of MPVPictures
that are separately allocated and are mostly accessed via pointers
(cur|last|next)_pic_ptr; they are also used to store AVFrames in the
encoder (necessary due to B-frames). As the name implies, each of the
former is directly associated with one of the _ptr pointers:
They actually share the same underlying buffers, but the ones
that are part of the context can have their data pointers offset
and their linesize doubled for field pictures.

Up until now, each of these had their own references; in particular,
there was an underlying av_frame_ref() to sync cur_pic and cur_pic_ptr
etc. This is wasteful.

This commit changes this relationship: cur_pic, last_pic and next_pic
now become MPVWorkPictures; this structure does not have an AVFrame
at all any more, but only the cached values of data and linesize.
It also contains a pointer to the corresponding MPVPicture, establishing
a more natural relationsship between the two.
This already means that creating the context-pictures from the pointers
can no longer fail.

What has not been changed is the fact that the MPVPicture* pointers
are not ownership pointers and that the MPVPictures are part of an
array of MPVPictures that is owned by a single AVCodecContext.
Doing so will be done in a latter commit.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-12 11:38:13 +02:00
Andreas Rheinhardt
dac15a5b6e avcodec/vc1_mc: Don't check AVFrame INTERLACE flags
Instead cache these values in VC1Context to avoid the indirection
and AND.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-12 11:37:33 +02:00
Andreas Rheinhardt
59422955cf avcodec/mpegpicture: Rename Picture->MPVPicture
Picture is just too generic.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-12 11:36:09 +02:00
Andreas Rheinhardt
2dfe7c1e40 avcodec/mpegvideo_enc: Move copying properties to alloc_picture()
This way said function sets everything (except for the actual
contents of the frame's data). Also rename it to prepare_picture()
given its new role.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-12 11:32:35 +02:00
Andreas Rheinhardt
8225d2da73 avcodec/mpegvideo_enc: Pass AVFrame*, not Picture* to alloc_picture()
It now only deals with the AVFrame and no longer with the accessories.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-12 11:32:25 +02:00
Andreas Rheinhardt
89ca63cc9c avcodec/mpegpicture: Split ff_alloc_picture() into check and alloc part
ff_alloc_picture() currently does two things: It checks the
consistency of the linesize (which should not be necessary, but is)
and it allocates certain buffers. (It does not actually allocate
the picture buffers, so its name is misleading.)
This commit splits it into two separate functions. The rationale
for this is that for the encoders, every picture needs its linesizes
checked, but not every picture needs these extra buffers.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-12 11:27:25 +02:00
Andreas Rheinhardt
042117da75 avcodec/mpegpicture: Improve error messages and code
Make it clear that this is not a failure of get_buffer/the user,
but a deficit of mpegvideo.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-12 11:27:15 +02:00
Andreas Rheinhardt
8c59b5aa6b avcodec/vc1_pred: Remove unused function parameter
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-12 11:27:04 +02:00
Andreas Rheinhardt
dda009b97d avcodec/mpegvideo: Add const where appropriate
Specifically, add const to the pointed-to-type of pointers
that point to something static or that belong to last_pic
or next_pic (because modifying these might lead to data races).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-12 11:26:51 +02:00
Andreas Rheinhardt
f1c4e8950e avcodec/rv30, rv34, rv40: Avoid indirection
Use the cached values from MpegEncContext.(cur|last|next)_pic
instead of the corresponding *_pic_ptr.
Also do the same in wmv2dec.c and mpegvideo_enc.c.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-12 11:22:41 +02:00
Andreas Rheinhardt
7814dd77aa avcodec/mpegpicture: Cache AVFrame.data and linesize values
This avoids an indirection and is in preparation for removing
the AVFrame from MpegEncContext.(cur|last|next)_pic altogether.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-12 11:20:56 +02:00
Andreas Rheinhardt
1c40a17922 avcodec/mpegpicture: Reduce value of MAX_PLANES define
No mpegvideo based codec supports alpha.
While just at it, also make the define shorter.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-12 11:20:27 +02:00
Andreas Rheinhardt
ec1eba792a avcodec/mpegvideo: Shorten variable names
current_picture->cur_pic, last_picture->last_pic, similarly
for new_picture and next_picture.
Also rename the corresponding *_ptr fields.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-12 11:19:44 +02:00
Andreas Rheinhardt
3a4e7694a1 avcodec/mpegvideo: Restrict resetting mbskip_table to MPEG-4 decoder
This is done due to invalid input and therefore the encoder is not
affected by it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-12 11:19:39 +02:00
Andreas Rheinhardt
47e43c19cb avcodec/h263: Move setting mbskip_table to decoder/encoders
This removes a branch from H.263 based decoders.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-12 11:19:17 +02:00
Andreas Rheinhardt
9645eeb485 avcodec/mpegvideo: Reindent after the previous commit
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-12 11:19:15 +02:00
Andreas Rheinhardt
101ed72c2f avcodec/h263, mpeg(picture|video): Only allocate mbskip_table for MPEG-4
It is the only user of said table and doing so is especially
important given that this buffer is zeroed every time.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-12 11:14:32 +02:00
Andreas Rheinhardt
2cbca73975 avcodec/h263: Move encoder-only part out of ff_h263_update_motion_val()
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-12 11:14:13 +02:00
Andreas Rheinhardt
bed17eba47 avcodec/mpegpicture: Use RefStruct-pool API
It involves less allocations and therefore has less
potential errors to be checked. One consequence thereof
is that updating the picture tables can no longer fail.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-12 11:13:03 +02:00
Andreas Rheinhardt
6450cfcd10 avcodec/mpegpicture: Reindent after the previous commit
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-12 11:12:59 +02:00
Andreas Rheinhardt
788892d647 avcodec/mpegvideo, mpegpicture: Add buffer pool
This avoids constant allocations+frees and will also allow
to simply switch to the RefStruct API, thereby avoiding
the overhead of the AVBuffer API.
It also simplifies the code, because it removes the "needs_realloc"
field: It was added in 435c0b87d2,
before the introduction of the AVBuffer API: given that these buffers
may be used by different threads, they were not freed immediately
and instead were marked as being freed later by setting needs_realloc.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-12 11:08:19 +02:00
Andreas Rheinhardt
a95591dbfd avcodec/mpegvideo: Redo aligning mb_height for VC-1
VC-1 can switch from between being progressive and interlaced
on a per-frame basis. In the latter case, the number of macroblocks
is aligned to two (or equivalently, the height to 32); therefore
certain buffers are allocated for the bigger mb_height
(see 950fb8acb4 and
017e234c20).

This commit changes how this is done: Aligning these buffers is
restricted to VC-1 and it is done directly by aligning
mb_height (but not MpegEncContext.mb_height) instead of
adding something in an ad-hoc manner.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-12 11:05:12 +02:00
Andreas Rheinhardt
7ad13e173b avcodec/mpegpicture: Always reset mbskip_table
Codecs call ff_find_unused_picture() to get the index of
an unused picture; said picture may have buffers left
from using it previously (these buffers are intentionally
not unreferenced so that it might be possible to reuse them;
they are only reused when they are writable, otherwise
they are replaced by new, zeroed buffers). They should
not make any assumptions about which picture they get.

Yet this is not true for mbskip_table and damaged bitstreams.
When one returns old unused slots randomly, the output
becomes nondeterministic. This can't happen now (see below),
but it will be possible once mpegpicture uses proper pools
for the picture tables.

The following discussion uses the sample created via
ffmpeg -bitexact -i fate-suite/svq3/Vertical400kbit.sorenson3.mov -ps 50 -bf 2 -bitexact -an -qscale 5 -ss 40 -error_rate 4 -threads 1 out.avi

When decoding this with one thread, the slots are as follows:
Cur 0 (type I), last -1, Next -1; cur refcount -1, not reusing buffers
Cur 1 (type P), last -1, Next 0; cur refcount -1, not reusing buffers
Cur 2 (type B), last 0, Next 1; cur refcount -1, not reusing buffers
Cur 2 (type B), last 0, Next 1; cur refcount 2, not reusing buffers
Cur 0 (type P), last 0, Next 1; cur refcount 2, not reusing buffers
Cur 2 (type B), last 1, Next 0; cur refcount 1, reusing buffers
Cur 2 (type B), last 1, Next 0; cur refcount 2, not reusing buffers
Cur 1 (type P), last 1, Next 0; cur refcount 2, not reusing buffers
Cur 2 (type B), last 0, Next 1; cur refcount 1, reusing buffers
Cur 2 (type B), last 0, Next 1; cur refcount 2, not reusing buffers
Cur 0 (type I), last 0, Next 1; cur refcount 2, not reusing buffers
Cur 2 (type B), last 1, Next 0; cur refcount 1, reusing buffers
Cur 2 (type B), last 1, Next 0; cur refcount 2, not reusing buffers
Cur 1 (type P), last 1, Next 0; cur refcount 2, not reusing buffers

After the slots have been filled initially, the buffers are only
reused for the first B-frame in a B-frame chain:
a) When the new picture is an I or a P frame, the slot of the backward
reference is cleared and reused for the new frame (as has been said,
"cleared" does not mean that the auxiliary buffers have been
unreferenced). Given that not only the slot in the picture array,
but also MpegEncContext.last_picture contain references to these
auxiliary buffers, they are not writable and are therefore not reused,
but replaced by new, zero-allocated buffers.
b) When the new picture is the first B-frame in a B-frame chain,
the two reference slots are kept as-is and one gets a slot that
does not share its auxiliary buffers with any of MpegEncContext.
current_picture, last_picture, next_picture. The buffers are
therefore writable and are reused.
c) When the new picture is a B-frame that is not the first frame
in a B-frame chain, ff_mpv_frame_start() reuses the slot occupied
by the preceding B-frame. Said slot shares its auxilary buffers
with MpegEncContext.current_picture, so that they are not considered
writable and are therefore not reused.

When using frame-threading, the slots are made to match the one
from the last thread, so that the above analysis is mostly the same
with one exception: Other threads may also have references to these
buffers, so that initial B-frames of a B-frame chain need no longer
have writable/reusable buffers. In particular, all I and P-frames
always use new, zeroed buffers. Because only the mbskip_tables of
I- and P-frames are ever used, it follows that there is currently
no problem with using stale values for them at all.

Yet as the analysis shows this is very fragile:
1. MpegEncContext.(current|last|next)_picture need not have
references of their own, but they have them and this influences
the writability decision.
2. It would not work if the slots were returned in a truely random
fashion or if there were a proper pool used.

Therefore this commit always resets said buffer. This is in preparation
for actually adding such a pool (where the checksums for said sample
would otherwise be depending on the number of threads used for
decoding).

Future commits will restrict this to only the codecs for which
it is necessary (namely the MPEG-4 decoder).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-12 11:01:24 +02:00
Andreas Rheinhardt
71ff9217f7 avcodec/mpegpicture: Always reset motion val buffer
Codecs call ff_find_unused_picture() to get the index of
an unused picture; said picture may have buffers left
from using it previously (these buffers are intentionally
not unreferenced so that it might be possible to reuse them;
this is mpegvideo's version of a bufferpool). They should
not make any assumptions about which picture they get.
Yet somehow this is not true when decoding OBMC: Returning
random empty pictures (instead of the first one) leads
to nondeterministic results; similarly, explicitly
rezeroing the buffer before handing it over to the codec
changes the outcome of the h263-obmc tests, but it makes it
independent of the returned pictures. Therefore this commit
does so.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-12 11:01:07 +02:00
Andreas Rheinhardt
caac9740f8 avcodec/mpegvideo: Only allocate cbp_table, pred_dir_table when needed
Namely for the MPEG-4 decoder.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-12 11:00:57 +02:00
Andreas Rheinhardt
582d828f75 avcodec/mpegvideo: Don't reset coded_block unnecessarily
coded_block is only used for I-frames, so it is unnecessary
to reset it in ff_clean_intra_table_entries() (which
cleans certain tables for a non-intra MB).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-12 10:54:27 +02:00
Andreas Rheinhardt
ba033acb56 avcodec/mpegvideo: Only allocate coded_block when needed
It is only needed for msmpeg4v3, wmv1, wmv2 and VC-1.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-12 10:54:08 +02:00
Andreas Rheinhardt
1a5c21daee avcodec/msmpeg4enc: Only calculate coded_cbp when used
With this patch, msmpeg4v1 and msmpeg4v2 no longer use
MpegEncContext.coded_block.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-12 10:53:23 +02:00
Andreas Rheinhardt
60d4c8a137 avcodec/mpegvideo_motion: Avoid constant function argument
Always 8.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-12 10:53:13 +02:00
Andreas Rheinhardt
55e81306bf avcodec/mpegvideo_motion: Optimize check away
When !CONFIG_SMALL, we create separate functions for FMT_MPEG1
(i.e. for MPEG-1/2); given that there are only three possibilities
for out_format (FMT_MPEG1, FMT_H263 and FMT_H261 -- MJPEG and SpeedHQ
are both intra-only and do not have motion vectors at all, ergo
they don't call this function), one can optimize MPEG-1/2-only code
away in mpeg_motion_internal().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-12 10:51:16 +02:00
Andreas Rheinhardt
5f505995db avcodec/mpegvideo_motion: Optimize check away
Only MPEG-2 can have field motion vectors with coded fields.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-12 10:50:57 +02:00
Andreas Rheinhardt
f44d212e0e avcodec/mpegvideo_motion: Remove dead checks for existence of reference
These references now always exist due to dummy frames.
Also remove the corresponding checks in the lowres code
in mpegvideo_dec.c.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-12 10:50:39 +02:00
Andreas Rheinhardt
c85508f5a9 avcodec/mpeg12dec: Allocate dummy frames for non-I fields
MPEG-2 allows to pair an intra field (as first field) together
with a P-field. In this case a conformant bitstream has to satisfy
certain restrictions in order to ensure that only the I field
is used for prediction. See section 7.6.3.5 of the MPEG-2
specifications.

We do not check these restrictions; normally we simply allocate
dummy frames for reference in order to avoid checks lateron.
This happens in ff_mpv_frame_start() and therefore does not happen
for a second field. This is inconsistent. Fix this by allocating
these dummy frames for the second field, too.

This already fixes two bugs:
1. Undefined pointer arithmetic in prefetch_motion() in
mpegvideo_motion.c where it is simply presumed that the reference
frame exists.
2. Several MPEG-2 hardware accelerations rely on last_picture
being allocated for P pictures and next picture for B pictures;
e.g. VDPAU returns VDP_STATUS_INVALID_HANDLE when decoding
an I-P fields pair because the forward_reference was set incorrectly.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-12 10:50:12 +02:00
Andreas Rheinhardt
73676dd47a avcodec/mpegpicture: Mark dummy frames as such
This will allow to avoid outputting them.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-12 10:49:57 +02:00
Andreas Rheinhardt
99543c93ec avcodec/mpegvideo_dec: Factor allocating dummy frames out
This will allow to reuse it to allocate dummy frames for
the second field (which can be a P-field even if the first
field was an intra field).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-12 10:49:24 +02:00
Andreas Rheinhardt
a30c95ed8a avcodec/mpegvideo_dec: Sync linesize and uvlinesize between threads
linesize and uvlinesize are supposed to be the common linesize of all
the Y/UV-planes of all the currently cached pictures.
ff_mpeg_update_thread_context() syncs the pictures, yet it did not sync
linesize and uvlinesize. This mostly works, because ff_alloc_picture()
only accepts new pictures if they coincide with the linesize of the
already provided pictures (if any).  Yet there is a catch: Linesize
changes are accepted when the dimensions change (in which case the
cached frames are discarded).

So imagine a scenario where all frame threads use the same dimension A
until a frame with a different dimension B is encountered in the
bitstream, only to be instantly reverted to A in the next picture. If
the user changes the linesize of the frames upon the change to dimension
B and keeps the linesize thereafter (possible if B > A),
ff_alloc_picture() will report an error when frame-threading is in use:
The thread decoding B will perform a frame size change and so will the
next thread in ff_mpeg_update_thread_context() as well as when decoding
its picture. But the next thread will (presuming it is not the same
thread that decoded B, i.e. presuming >= 3 threads) not perform a frame
size change, because the new frame size coincides with its old frame
size, yet the linesize it expects from ff_alloc_picture() is outdated,
so that it errors out.

It is also possible for the user to use the original linesizes for
the frame after the frame that reverted back to A; this will be
accepted, yet the assumption that of all pictures are the same
will be broken, leading to segfaults.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-12 10:49:03 +02:00
Andreas Rheinhardt
d4b63885a6 avcodec/mpegpicture: Store linesize in ScratchpadContext
The mpegvideo-based codecs currently require the linesize to be
constant (except when the frame dimensions change); one reason
for this is that certain scratch buffers whose size depend on
linesize are only allocated once and are presumed to be correctly
sized if the pointers are != NULL.

This commit changes this by storing the actual linesize these
buffers belong to and reallocating the buffers if it does not
suffice. This is not enough to actually support changing linesizes,
but it is a start. And it is a prerequisite for the next patch.

Also don't emit an error message in case the source ctx's
edge_emu_buffer is unset in ff_mpeg_update_thread_context().
It need not be an error at all; e.g. it is a perfectly normal
state in case a hardware acceleration is used as the scratch
buffers are not allocated in this case (it is easy to run into
this issue with MPEG-4) or if the src context was not initialized
at all (e.g. because the first packet contained garbage).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-12 10:47:44 +02:00
Andreas Rheinhardt
0aaabe1fd7 avcodec/get_buffer: Remove redundant check
It is unnecessary to check for whether the number of planes
of an already existing audio pool coincides with the number
of planes to use for the frame: If the common format of both
is planar, then the number of planes coincides with the number
of channels for which there is already a check*; if not,
then both the existing pool as well as the frame use one pool.

*: In fact, one could reuse the pool in this case even if the
number of channels changes.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-12 10:37:16 +02:00
Andreas Rheinhardt
2786d34712 avcodec/ratecontrol: Avoid padding in RateControlEntry
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-12 10:37:11 +02:00
Andreas Rheinhardt
685cda26aa avcodec/mpegvideo, ratecontrol: Remove write-only skip_count
Write-only since 6cf0cb8935.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-12 10:36:37 +02:00
Andreas Rheinhardt
68a06640b1 avcodec/ratecontrol: Don't call ff_rate_control_uninit() ourselves
It is currently done inconsistently: Only one error path
(namely the one from init_pass2()) made ff_rate_control_init()
call ff_rate_control_uninit(); in other error paths
cleanup was left to the caller.

Given that the only caller of this function already performs
the necessary cleanup this commit changes this to always
rely on the caller to perform cleanup on error.

Also return the error code from init_pass2().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-12 10:36:30 +02:00
Andreas Rheinhardt
0c9e04b0e2 avcodec/ratecontrol: Pass RCContext directly in ff_rate_control_uninit()
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-12 10:36:16 +02:00
Andreas Rheinhardt
ba28222a14 avcodec/ratecontrol: Fix double free on error
Happens on init_pass2() failure.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-12 10:36:01 +02:00