aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/mpegvideo.h
Commit message (Collapse)AuthorAgeFilesLines
* avcodec: remove FF_API_FLAG_TRUNCATEDJames Almer2023-02-091-7/+0
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/mpeg4videodec: duplicate the last decoded frame when the last coded ↵James Almer2022-12-121-0/+1
| | | | | | | | frame was skipped This ensures the video stream duration is not lost after decoding. Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/h263dec: Avoid parsing extradata repeatedlyMichael Niedermayer2022-11-281-0/+1
| | | | | | | | Fixes: Timeout Fixes: 52329/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MPEG4_fuzzer-4716563886637056 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/mpegvideo: Don't use ScanTable where unnecessaryAndreas Rheinhardt2022-10-241-2/+2
| | | | | | | | | For the intra_[hv]_scantables, only ScanTable.permutated is used, so one only needs to keep that. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Reviewed-by: Peter Ross <pross@xvid.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideo: Move ASM-offset warning to its proper placeAndreas Rheinhardt2022-10-241-3/+4
| | | | | Reviewed-by: Peter Ross <pross@xvid.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/idctdsp: Move ScanTable to mpegvideoAndreas Rheinhardt2022-10-241-0/+11
| | | | | | | Only used there. Reviewed-by: Peter Ross <pross@xvid.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideo: Move sprite-related fields to Mpeg4DecContextAndreas Rheinhardt2022-10-201-4/+0
| | | | | | Only used there. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideodsp: Make MpegVideoDSP MPEG-4 onlyAndreas Rheinhardt2022-10-201-2/+0
| | | | | | | | It is only used by gmc/gmc1 which is only used by the MPEG-4 decoder, so move it to Mpeg4DecContext and rename it to Mpeg4VideoDSP. Also compile it iff the MPEG-4 decoder is compiled. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideo: Split ff_mpv_reconstruct_mb() into de/encoder partAndreas Rheinhardt2022-10-201-2/+0
| | | | | | | | | | | | | | | | | | | | | | This has the advantage of not having to check for whether a given MpegEncContext is actually a decoder or an encoder context at runtime. To do so, mpv_reconstruct_mb_internal() is moved into a new template file that is included by both mpegvideo_enc.c and mpegvideo_dec.c; the decoder-only code (mainly lowres) are also moved to mpegvideo_dec.c. The is_encoder checks are changed to #if IS_ENCODER in order to avoid having to include headers for decoder-only functions in mpegvideo_enc.c. This approach also has the advantage that it is easy to adapt mpv_reconstruct_mb_internal() to using different structures for decoders and encoders (e.g. the check for whether a macroblock should be processed for the encoder or not uses MpegEncContext elements that make no sense for decoders and should not be part of their context). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideo: Move VIDEO_FORMAT_* defines to mpeg12enc.cAndreas Rheinhardt2022-10-201-6/+0
| | | | | | Forgotten in f899e3b51bc85c45f54f7ac64abfbde6b2cd7d3d. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegpicture: Move encoding_error and mb_var_sum to MpegEncCtxAndreas Rheinhardt2022-08-101-1/+4
| | | | | | | | These fields are only ever set by the encoder for the current picture and for no other picture. So only one set of these values needs to exist, so move them to MpegEncContext. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegpicture: Move mb_var, mc_mb_var and mb_mean to MpegEncCtxAndreas Rheinhardt2022-08-091-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These tables are only used by encoders and only for the current picture; ergo they need not be put into the picture at all, but rather into the encoder's context. They also don't need to be refcounted, because there is only one owner. In contrast to this, the earlier code refcounts them which incurs unnecessary overhead. These references are not unreferenced in ff_mpeg_unref_picture() (they are kept in order to have something like a buffer pool), so that several buffers are kept at the same time, although only one is needed, thereby wasting memory. The code also propagates references to other pictures not part of the pictures array (namely the copy of the current/next/last picture in the MpegEncContext which get references of their own). These references are not unreferenced in ff_mpeg_unref_picture() (the buffers are probably kept in order to have something like a pool), yet if the current picture is a B-frame, it gets unreferenced at the end of ff_mpv_encode_picture() and its slot in the picture array will therefore be reused the next time; but the copy of the current picture also still has its references and therefore these buffers will be made duplicated in order to make them writable in the next call to ff_mpv_encode_picture(). This is of course unnecessary. Finally, ff_find_unused_picture() is supposed to just return any unused picture and the code is supposed to work with it; yet for the vsynth*-mpeg4-adap tests the result depends upon the content of these buffers; given that this patchset changes the content of these buffers (the initial content is now the state of these buffers after encoding the last frame; before this patch the buffers used came from the last picture that occupied the same slot in the picture array) their ref-files needed to be changed. This points to a bug somewhere (if one removes the initialization, one gets uninitialized reads in adaptive_quantization in ratecontrol.c). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideo_motion: Constify ff_mpv_motionAndreas Rheinhardt2022-08-051-1/+1
| | | | | | | | | | | | Also constify the corresponding code in mpegvideo.c that handles lowres. (Unfortunately, not everything that is const could be constified: ref_picture could be made const uint8_t* const* if C allowed the safe automatic conversion from uint8_t**; and pix_op, qpix_op could be made to point to const function pointers, but C's handling of const in pointers to arrays is broken.) Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideo: Inline values in ff_update_block_index()Andreas Rheinhardt2022-07-311-5/+7
| | | | | | | | | This is possible for most of the callers, because e.g. only the MPEG-4 decoder can have bits_per_raw_sample > 8. Also most mpegvideo-based codecs are 420 only. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mjpegenc: Remove ineffective pred optionAndreas Rheinhardt2022-05-241-4/+0
| | | | | | Never did anything, so it is removed immediately. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideoenc: Remove ineffective optionsAndreas Rheinhardt2022-05-241-1/+1
| | | | | | | | | | | | | | | | This commit removes the ineffective FF_MPV_DEPRECATED_ options, namely mpeg_quant (this is only an option for MPEG-4), a53cc (this is only an option for MPEG-2), force_duplicated_matrix (applies only to MJPEG) and b_strategy, b_sensitivity and brd_scale (these options only make sense for encoders supporting B-frames, which currently means the MPEG-1/2 and MPEG-4 encoders). Given that these options never changed the outcome of encoding, they are removed at once. Notice that the options for the encoders for which it made sense are not affected by this. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideo: Move float.h inclusion to mpegvideoenc.hAndreas Rheinhardt2022-05-191-2/+0
| | | | | | It is only needed for the options in mpegvideoenc.h. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideo: Make new_picture an ordinary AVFrameAndreas Rheinhardt2022-04-011-2/+2
| | | | | | | | | It is currently a "Picture", an mpegvideo-specific type that has a lot of baggage, all of which is unnecessary for new_picture, because only its embedded AVFrame is ever used. So just use an ordinary AVFrame. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideo: Remove strict_std_compliance from MpegEncContextAndreas Rheinhardt2022-04-011-1/+0
| | | | | | It just duplicates AVCodecContext.strict_std_compliance. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/speedhqenc: Add SpeedHQEncContext and move slice_start to itAndreas Rheinhardt2022-04-011-3/+0
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* lavc/mpeg*: drop the XvMC hwaccel codeAnton Khirnov2022-02-151-2/+0
| | | | | XvMC was last relevant over 10 years ago, if ever. There is no reason to use it today.
* avcodec/mpegvideo: Constify src of ff_update_duplicate_context()Andreas Rheinhardt2022-02-131-1/+1
| | | | | | | Also do the same for update_duplicate_context_after_me() in mpegvideo_enc.c. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideo: Remove write-only [fb]_codeAndreas Rheinhardt2022-02-131-2/+0
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideo: Move decoder-only stuff to a new headerAndreas Rheinhardt2022-02-131-28/+0
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideo: Move encoder-only stuff to a new headerAndreas Rheinhardt2022-02-131-127/+0
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/msmpegenc: Add MSMPEG4EncContext and move ac_stats to itAndreas Rheinhardt2022-02-131-2/+0
| | | | | | Also avoid the allocation by making it part of the context. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideo: Enable private contextsAndreas Rheinhardt2022-02-131-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | MpegEncContext is used by many different codecs and every one of these uses just a subset of its fields. If one tries to separate this and e.g. add a real MpegContext and extension structures (say MpegDecContext and MpegEncContext), one runs into two difficulties: a) Some code is shared between decoder and encoder of the same format and they therefore use the same contexts, either MpegEncContext itself or identical extensions thereof. The latter is the case for H.261 as well as WMV2. b) In case of slice threading, the generic code can only allocate and initialize the structure it knows about; right now this is an MpegEncContext. If the codec has an even more extensive structure, it is only available for the main thread's MpegEncContext. Fixing this would involve making ff_mpv_common_init() aware of the size the size of slice context to allocate and would be part of separating the main thread's context from the slice contexts in general. This commit only intends to tackle the first issue by adding a pointer to MpegEncContext that codecs can set to a common context so that the aforementioned codecs can use this context (together with the MpegEncContext) in their common code. This will allow to move fields only used by the main thread to more specialized contexts. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideo: Use offset instead of pointer for vbv_delayAndreas Rheinhardt2022-01-291-1/+1
| | | | | | | | | | An offset has the advantage of not needing to be updated when the buffer is reallocated. Furthermore, the way the pointer is currently updated is undefined behaviour in case the pointer is not already set (i.e. when not encoding MPEG-1/2), because it calculates the nonsense NULL - s->pb.buf. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideo: Move MPEG-4 Simple Studio Profile fields to mpeg4videoAndreas Rheinhardt2022-01-291-4/+0
| | | | | | | | | | This is possible now that dealing with the Simple Studio Profile has been moved to mpeg4videodec.c. It also allows to avoid allocations, because one can simply put the required buffers on the context (if one made these buffers part of MpegEncContext, the memory would be wasted for every codec other than MPEG-4). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideo: Move frame_rate_index to (Mpeg1|MPEG12Enc)ContextAndreas Rheinhardt2022-01-291-1/+0
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideo: Move gop_picture_number to MPEG12EncContextAndreas Rheinhardt2022-01-291-1/+0
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideo: Move timecode_frame_start to Mpeg1ContextAndreas Rheinhardt2022-01-291-1/+0
| | | | | | It is only used there and only by the main thread. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideo: Move aspect_ratio_info to Mpeg1ContextAndreas Rheinhardt2022-01-291-1/+0
| | | | | | Only used there and only by the main thread. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpeg4?video: Move vo_type to Mpeg4DecContextAndreas Rheinhardt2022-01-291-1/+0
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideo, svq3: Remove unused next_p_frame_damagedAndreas Rheinhardt2022-01-131-1/+0
| | | | | | Always zero since 4d2858deac5213eaddfdc06f98379b6325d7b953. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideo: Move decoding-only code into a new fileAndreas Rheinhardt2022-01-041-0/+22
| | | | | | | This will allow to disable this code altogether when all decoders are disabled. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpeg12enc: Move options-related fields to MPEG12EncContextAndreas Rheinhardt2022-01-041-9/+0
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpeg12enc: Add custom context, move mpeg2_frame_rate_ext to itAndreas Rheinhardt2022-01-041-1/+0
| | | | | | It is only used here. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpeg12enc: Simplify check for A53 closed captionsAndreas Rheinhardt2022-01-041-1/+1
| | | | | | | | | | | | | | | The a53_cc option is only useful and meaningful for MPEG-2, yet it was accidentally added for all mpegvideo-based encoders. This means that it is possible for a53_cc to be set for other encoders as well. This commit changes this and reroutes a53_cc to the dummy field in MpegEncContext for all codecs for which it is not supported. This allows to avoid a check for the current codec in mpeg12enc.c. Also add a compile-time check for whether the MPEG-2 encoder is available while at it. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideo: Remove unnecessary headersAndreas Rheinhardt2022-01-041-2/+1
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mjpegenc: Deprecate unused prediction typeAndreas Rheinhardt2022-01-041-2/+1
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideo: Move MJPEG/AMV-only fields to MJpegContextAndreas Rheinhardt2022-01-041-3/+5
| | | | | | | This is possible now that MJpegContext is allocated jointly with MpegEncContext as part of the AVCodecContext's private data. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideo: Allocate several buffers jointlyAndreas Rheinhardt2021-12-171-4/+4
| | | | | | Reduces the amount of allocations and frees. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideo: Move closed_gop to Mpeg1ContextAndreas Rheinhardt2021-12-171-1/+0
| | | | | | Only used there and only by the main thread. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/(h263|mpeg4?video)_parser: Make *_find_frame_end() staticAndreas Rheinhardt2021-09-201-0/+2
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* lavc: deprecate AV_CODEC_(FLAG|CAP)_TRUNCATEDAnton Khirnov2021-09-201-0/+2
| | | | | | | | | | It is supported only by a few decoders (h263, h263p, mpeg(1|2|)video and mpeg4) and is entirely redundant with parsers. Furthermore, using it leads to missing frames, as flushing the decoder at the end does not work properly. Co-authored-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideo: Move startcodes to mpeg12.hAndreas Rheinhardt2021-09-201-12/+0
| | | | | | | And remove the MPEG-4-specific SLICE_START_CODE, which duplicates SLICE_STARTCODE. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideo_enc: Deduplicate ff_mpv_generic_options-based AVClassesAndreas Rheinhardt2021-07-081-1/+1
| | | | | | | | The child_class_next API relied on different AVCodecs to use different AVClasses; yet this API has been replaced by child_class_iterate. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec: Remove deprecated old encode/decode APIsAndreas Rheinhardt2021-04-271-1/+1
| | | | | | | | Deprecated in commits 7fc329e2dd6226dfecaa4a1d7adf353bf2773726 and 31f6a4b4b83aca1d73f3cfc99ce2b39331970bf3. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/mpegvideo: Remove deprecated rc_strategy optionAndreas Rheinhardt2021-04-271-12/+0
| | | | | | | Deprecated in d05c3b9ceeb9d00d4500c376448230e45f6ab108. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>