summaryrefslogtreecommitdiff
path: root/libavcodec/mpegvideo_enc.c
Commit message (Collapse)AuthorAge
* lavc/mpegvideo_enc: support AV_CODEC_CAP_ENCODER_RECON_FRAMEAnton Khirnov2022-08-02
|
* avcodec/mpegvideo: Inline values in ff_update_block_index()Andreas Rheinhardt2022-07-31
| | | | | | | | | 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/mpegvideo_enc: Unify the code styleWenbin Chen2022-07-09
| | | | | | | Change whitespace and add newline to unify the code style. Signed-off-by: Wenbin Chen <wenbin.chen@intel.com> Signed-off-by: Marton Balint <cus@passwd.hu>
* avcodec/mpegvideo_enc: Fix a chroma mb size error in sse_mb()Wenbin Chen2022-07-09
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | For 422 frames we should not use hard coded 8 to calculate mb size for uv plane. Chroma shift should be taken into consideration to be compatiple with different sampling format. The error is reported by fate test when av_cpu_max_align() return 64 on the platform supporting AVX512. This is a hidden error and it is exposed after commit 17a59a634c39b00a680c6ebbaea58db95594d13d. mpeg2enc has a mechanism to reuse frames. When it computes SSE (sum of squared error) on current mb, reconstructed mb will be wrote to the previous mb space, so that the memory can be saved. However if the align is 64, the frame is shared in somewhere else, so the frame cannot be reused and a new frame to store reconstrued data is created. Because the height of mb is wrong when compute sse on 422 frame, starting from the second line of macro block, changed data is read when frame is reused (we need to read row 16 rather than row 8 if frame is 422), and unchanged data is read when frame is not reused (a new frame is created so the original frame will not be changed). That is why commit 17a59a634c39b00a680c6ebbaea58db95594d13d exposes this issue, because it add av_cpu_max_align() and this function return 64 on platform supporting AVX512 which lead to creating a frame in mpeg2enc, and this lead to the different outputs. Signed-off-by: Wenbin Chen <wenbin.chen@intel.com> Signed-off-by: Marton Balint <cus@passwd.hu>
* all: Replace if (ARCH_FOO) checks by #if ARCH_FOOAndreas Rheinhardt2022-06-15
| | | | | | | | | | | | | | | | | | This is more spec-compliant because it does not rely on dead-code elimination by the compiler. Especially MSVC has problems with this, as can be seen in https://ffmpeg.org/pipermail/ffmpeg-devel/2022-May/296373.html or https://ffmpeg.org/pipermail/ffmpeg-devel/2022-May/297022.html This commit does not eliminate every instance where we rely on dead code elimination: It only tackles branching to the initialization of arch-specific dsp code, not e.g. all uses of CONFIG_ and HAVE_ checks. But maybe it is already enough to compile FFmpeg with MSVC with whole-programm-optimizations enabled (if one does not disable too many components). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideoenc: Remove ineffective optionsAndreas Rheinhardt2022-05-24
| | | | | | | | | | | | | | | | 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/mjpegenc: Remove pointless motion-estimation optionsAndreas Rheinhardt2022-05-24
| | | | | | | | (M)JPEG does not use motion estimation/motion vectors at all. These options therefore don't affect the output at all. So remove them. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideo_enc: Remove always-true checkAndreas Rheinhardt2022-04-14
| | | | | | | It is a remnant of the old way for user-supplied buffers; it is always-true since 93016f5d1d280f9cb7856883af287fa66affc04c. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideo_enc: Fix unnecessary linear growth of bufferAndreas Rheinhardt2022-04-14
| | | | | | | | | | | If one encodes MJPEG with a single slice and uses input with AV_FRAME_DATA_ICC_PROFILE side data, the current allocation code in ff_mpv_encode_picture() will always increase the size of the temporary buffer used for allocating packets by the size needed for to write the ICC chunk even when the current buffer is actually large enough. This commit fixes this. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideo_enc: Ignore ICC profile size when not MJPEGAndreas Rheinhardt2022-04-14
| | | | | | | | MJPEG is the only mpegvideo-based encoder making use of it. Fixes linking failures in case mpegvideo_enc.c is compiled with AMV, LJPEG and MJPEG encoders disabled. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mjpegenc: support writing ICC profilesNiklas Haas2022-04-11
| | | | | | | | | | | | | | | | This is mostly straightforward. The major complication is that, as a result of the 16-bit chunk size limitation, ICC profiles may need to be split up into multiple chunks. We also need to make sure to allocate enough extra space in the packet to fit the ICC profile, so modify both mpegvideo_enc.c and ljpegenc.c to take into account this extra overhead, failing cleanly if necessary. Also add a FATE transcode test to ensure that the ICC profile gets written (and read) correctly. Note that this ICC profile is smaller than 64 kB, so this doesn't test the APP2 chunk re-arranging code at all. Signed-off-by: Niklas Haas <git@haasn.dev>
* avcodec/mpegvideo_enc: Remove redundant unref+refAndreas Rheinhardt2022-04-01
| | | | | | Setting current_picture will already be done in frame_start(). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideo: Make new_picture an ordinary AVFrameAndreas Rheinhardt2022-04-01
| | | | | | | | | 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-01
| | | | | | It just duplicates AVCodecContext.strict_std_compliance. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideo_enc: Allow slices only for slice-thread-able codecsAndreas Rheinhardt2022-04-01
| | | | | | | | | | | | | | | | | One can use slices without slice-threading. The results for mpegvideo-encoders are abysmal: AMV, SpeedHQ, H.263, RV10, RV20, MSMPEG4v2, MSMPEG4v3 and WMV1 produce broken files. WMV2 meanwhile expects the MpegEncContext given to ff_wmv2_encode_mb() to be at the beginning of a Wmv2Context (a structure that this encoder shares with the WMV2 decoder), yet this is only true for the main context and not for the slice contexts, leading to segfaults. SpeedHQ additionally triggers an av_assert2, because it is not byte-aligned at a position where it ought to be byte-aligned. Given that no codec not supporting slice threading works this commit disallows using slices unless the encoder supports slice threading. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* configure: Use a separate config_components.h header for $ALL_COMPONENTSMartin Storsjö2022-03-16
| | | | | | | | This avoids unnecessary rebuilds of most source files if only the list of enabled components has changed, but not the other properties of the build, set in config.h. Signed-off-by: Martin Storsjö <martin@martin.st>
* avcodec/mpegvideo_enc: Remove unused parameter from encode_mb_hq()Andreas Rheinhardt2022-02-13
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideo_enc: Remove unused function parametersAndreas Rheinhardt2022-02-13
| | | | | | | Seems to have been always unused since these functions were introduced in 1f0cd30fd9b656122436ecd625656a04f6235fb3. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideo: Constify src of ff_update_duplicate_context()Andreas Rheinhardt2022-02-13
| | | | | | | 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-13
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideo_enc: Don't set picture_in_gop_number for slice threadsAndreas Rheinhardt2022-02-13
| | | | | | They don't ever read this value. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideo_enc: Don't find encoder by IDAndreas Rheinhardt2022-02-13
| | | | | | | | | | | | mpegvideo-based encoders supporting bframes implement this by opening encoders of their own to test how long the chains of bframes are supposed to be. The needed AVCodec was obtained via avcodec_find_encoder(). This is complicated, as the current encoder can be directly obtained. And it also is not guaranteed that one actually gets the current encoder or not another encoder for the same codec ID (the latter does not seem to be the case now). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideo: Move encoder-only stuff to a new headerAndreas Rheinhardt2022-02-13
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/rv10.h: Split header into decoder- and encoder-only partsAndreas Rheinhardt2022-02-13
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpeg12.h: Move encoder-only stuff into a new headerAndreas Rheinhardt2022-02-13
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/flv.h: Split header into encoder-only and decoder-only headersAndreas Rheinhardt2022-02-13
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpeg4video.h: Move encoder-only parts in a new fileAndreas Rheinhardt2022-02-13
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/h263.h: Move encoder-only stuff to a new header h263enc.hAndreas Rheinhardt2022-02-13
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/msmpegenc: Add MSMPEG4EncContext and move ac_stats to itAndreas Rheinhardt2022-02-13
| | | | | | Also avoid the allocation by making it part of the context. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/msmpeg4.h: Move encoder-only stuff to a new headerAndreas Rheinhardt2022-02-13
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/wmv2.h: Move encoder- and decoder-only parts to new headersAndreas Rheinhardt2022-02-13
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/h261: Move encoder-only stuff to a new headerAndreas Rheinhardt2022-02-13
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideo: Use offset instead of pointer for vbv_delayAndreas Rheinhardt2022-01-29
| | | | | | | | | | 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/mpegpicture: Add function to completely free MPEG-PictureAndreas Rheinhardt2022-01-29
| | | | | | | | | Also use said function in mpegvideo.c and mpegvideo_enc.c; and make ff_free_picture_tables() static as it isn't needed anymore outside of mpegpicture.c. Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideo_enc: Don't hardcode list of codecs supporting bframesAndreas Rheinhardt2022-01-29
| | | | | | Check for the encoder's AV_CODEC_CAP_DELAY instead. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideo_enc: Localize check for invalid number of b-framesAndreas Rheinhardt2022-01-29
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideo_enc: Move H.263p? encoders to ituh263enc.cAndreas Rheinhardt2022-01-29
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideo_enc: Move msmpeg4/wmv1 encoders to msmpeg4enc.cAndreas Rheinhardt2022-01-29
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideo_enc: Don't sync gop_picture_number among slice threadsAndreas Rheinhardt2022-01-29
| | | | | | It is only used by the main thread. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegpicture: Decrease size of encoding_error arrayAndreas Rheinhardt2022-01-13
| | | | | | | | | | | | | The current size is AV_NUM_DATA_POINTERS (i.e. eight). This number is chosen in order to minimize the amount of allocations for AVFrame.extended_(data|buf) for audio; it is meaningless for video for which four is sufficient. So decrease this array in order to minimize what is copied in ff_mpeg_ref_picture() and at the places that copy a whole MpegEncContext. Also do the same for snowenc. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpeg4video: Split off data in a header of its ownAndreas Rheinhardt2022-01-13
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideo_enc: Remove dead code at compile timeAndreas Rheinhardt2022-01-04
| | | | | | There are no encoders for interlaced dct that support 4:4:4. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideo_enc: Improve inlining of chroma_formatAndreas Rheinhardt2022-01-04
| | | | | | | | | | | | encode_mb() calls encode_mb_internal() three times, once for each supported chroma format. The reason for this is that some chroma format dependent parameters can then be inlined as encode_mb_internal() is marked as av_always_inline. Yet the most basic parameters based upon chroma format have not been inlined: The chroma format itself and the chroma subsampling parameters. This commit does so. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideo_enc: Don't merge decoder-only fieldsAndreas Rheinhardt2022-01-04
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideo_enc: Move updating mb_info to its only userAndreas Rheinhardt2022-01-04
| | | | | | It is a H.263 option. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideo_enc: Remove impossible branchAndreas Rheinhardt2022-01-04
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideo: Remove unnecessary headersAndreas Rheinhardt2022-01-04
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mjpegenc: Add wrapper for ff_mjpeg_encode_picture_header()Andreas Rheinhardt2022-01-04
| | | | | | | This factors the translation from MpegEncContext out and will enable further optimizations in the next commits. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideo_enc: Remove redundant checks for multithreadingAndreas Rheinhardt2022-01-04
| | | | | | | | | | | The generic code ensures that only codecs with the FF_CODEC_CAP_AUTO_THREADS internal cap ever have to handle the case avctx->thread_count == 0 themselves; moreover, it is also ensured generically that only codecs that support some form of threading have thread_count set to something else than one. So these checks are unnecessary. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/mpegvideo_enc: Move MJPEG init checks to mjpegenc.cAndreas Rheinhardt2022-01-04
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>