summaryrefslogtreecommitdiff
path: root/libavcodec/vorbisenc.c
Commit message (Collapse)AuthorAge
* avcodec: Make init-threadsafety the defaultAndreas Rheinhardt2022-07-18
| | | | | | | | | | | and remove FF_CODEC_CAP_INIT_THREADSAFE All our native codecs are already init-threadsafe (only wrappers for external libraries and hwaccels are typically not marked as init-threadsafe yet), so it is only natural for this to also be the default state. Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/codec_internal: Use union for FFCodec decode/encode callbacksAndreas Rheinhardt2022-04-05
| | | | | | | | | | | This is possible, because every given FFCodec has to implement exactly one of these. Doing so decreases sizeof(FFCodec) and therefore decreases the size of the binary. Notice that in case of position-independent code the decrease is in .data.rel.ro, so that this translates to decreased memory consumption. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/codec_internal: Add FFCodec, hide internal part of AVCodecAndreas Rheinhardt2022-03-21
| | | | | | | | | | | | | | | | Up until now, codec.h contains both public and private parts of AVCodec. This exposes the internals of AVCodec to users and leads them into the temptation of actually using them and forces us to forward-declare structures and types that users can't use at all. This commit changes this by adding a new structure FFCodec to codec_internal.h that extends AVCodec, i.e. contains the public AVCodec as first member; the private fields of AVCodec are moved to this structure, leaving codec.h clean. Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/internal: Move FF_CODEC_CAP_* to a new header codec_internal.hAndreas Rheinhardt2022-03-21
| | | | | | | | | | Also move FF_CODEC_TAGS_END as well as struct AVCodecDefault. This reduces the amount of files that have to include internal.h (which comes with quite a lot of indirect inclusions), as e.g. most encoders don't need it. It is furthemore in preparation for moving the private part of AVCodec out of the public codec.h. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* vorbis: convert to new channel layout APIAnton Khirnov2022-03-15
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/vorbisenc: Cleanup generically on init-failureAndreas Rheinhardt2022-02-11
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* Replace all occurences of av_mallocz_array() by av_calloc()Andreas Rheinhardt2021-09-20
| | | | | | | They do the same. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* libavcodec/vorbisenc: Add missing initial_paddingGuangyu Sun2021-07-12
| | | | | | | | | | | Vorbis has priming samples at the beginning. If the initial_padding is not set in the encoder, the total sample count will be one frame fewer than it should be. The result is that we get a truncated version of encoding. initial_padding should be set to the frame_size used in vorbis_encode_frame(). Signed-off-by: Guangyu Sun <gsun@roblox.com>
* avcodec/encode: Always use intermediate buffer in ff_alloc_packet2()Andreas Rheinhardt2021-06-08
| | | | | | | | | | | | | | | | | | | | | | | | | | | Up until now, ff_alloc_packet2() has a min_size parameter: It is supposed to be a lower bound on the final size of the packet to allocate. If it is not too far from the upper bound (namely, if it is at least half the upper bound), then ff_alloc_packet2() already allocates the final, already refcounted packet; if it is not, then the packet is not refcounted and its data only points to a buffer owned by the AVCodecContext (in this case, the packet will be made refcounted in encode_simple_internal() in libavcodec/encode.c). The goal of this was to avoid data copies and intermediate buffers if one has a precise lower bound. Yet those encoders for which precise lower bounds exist have recently been switched to ff_get_encode_buffer() (which automatically allocates final buffers), leaving only two encoders to actually set the min_size to something else than zero (namely aliaspixenc and hapenc). Both of these encoders use a very low lower bound that is not helpful in any nontrivial case. This commit therefore removes the min_size parameter as well as the codepath in ff_alloc_packet2() for the allocation of final buffers. Furthermore, the function has been renamed to ff_alloc_packet() and moved to encode.h alongside ff_get_encode_buffer(). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/vorbisenc: Combine codebooks, avoid relocationsAndreas Rheinhardt2021-05-12
| | | | | | | | | | | | | | | | | | | | The Vorbis encoder has an array of a structure containing all the ingredients for a codebook; this includes a pointer to the actual codebook and some even have a pointer to an array containing quant values. Each of these real codebooks is an array of its own. These pointers lead to relocations and therefore the array will be placed in .data.rel.ro and not in .rodata. This commit avoids the pointers altogether by combining all the actual codebooks into one big array; the actual codebooks are now accessed consecutively by incrementing the pointer used to access them by the length of the actual codebook that has just been dealt with (said length is contained in the structure describing the codebook). There is no downside to this given that these codebooks are already only used once during init. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/vorbisenc: Mark encoder as init-threadsafeAndreas Rheinhardt2021-05-12
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/vorbisenc: Don't free uninitialized pointersAndreas Rheinhardt2021-05-12
| | | | | | | | | | | | | The Vorbis encoder allocates several arrays destined to contain pointers to separately allocated arrays; yet these arrays are allocated without initializing them: They are uninitialized until their final values are stored in them; so if allocating one of the earlier subarrays fails, all of the remaining pointers to subarrays are still uninitialized. But they are used for freeing, resulting in crashes. Fix this by zero-initializing the arrays with subarrays. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec: Remove redundant freeing of extradata of encodersAndreas Rheinhardt2021-04-28
| | | | | | | | AVCodecContext.extradata is freed generically by libavcodec for encoders, so it is unnecessary for an encoder to do it on its own. Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec: Constify AVCodecsAndreas Rheinhardt2021-04-27
| | | | | | | | | | Given that the AVCodec.next pointer has now been removed, most of the AVCodecs are not modified at all any more and can therefore be made const (as this patch does); the only exceptions are the very few codecs for external libraries that have a init_static_data callback. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* Avoid intermediate bitcount for number of bytes in PutBitContextAndreas Rheinhardt2021-03-30
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/vorbisenc, wmavoice: Use put_bits_left() where appropriateAndreas Rheinhardt2021-03-30
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/vorbisenc: Remove always-false checkAndreas Rheinhardt2021-03-30
| | | | | | The PutBitContext is big enough: It has just been initialized to 8192B. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* vorbisenc: Check the return value of av_frame_cloneDerek Buitenhuis2017-11-26
| | | | | | Prevents a segfault when alloc fails. Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
* avcodec/vorbisenc: Fix mixed declaration and statementsMichael Niedermayer2017-09-16
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* vorbisenc: Stop tracking number of samples per frameTyler Jones2017-06-15
| | | | | | | | | Each frame is now padded with 0 values if not enough samples are present, and all frames are guaranteed to have exactly 1 << (venc->log2_blocksize[1] - 1) samples. Signed-off-by: Tyler Jones <tdjones879@gmail.com> Reviewed-by: Rostislav Pehlivanov <atomnuker@gmail.com>
* vorbisenc: Apply and output correct length window and mdctTyler Jones2017-06-15
| | | | | | | | | Usage of blocksize, window, mode, and mdct indexes are switched from default 0 to a default of 1 to better align with specs. A flag of 0 should correspond with short windows, a flag of 1 with long. Signed-off-by: Tyler Jones <tdjones879@gmail.com> Reviewed-by: Rostislav Pehlivanov <atomnuker@gmail.com>
* vorbisenc: Separate copying audio samples from windowingTyler Jones2017-06-15
| | | | | | | | | | | | Audio samples are shifted around when copying from the frame queue so that analysis can be done without negatively impacting calculation of the MDCT. Window coefficients are applied to the current two overlapped windows simultaneously instead of applying overlap for the next frame ahead of time. This improves readability when applying windows of varying lengths. Signed-off-by: Tyler Jones <tdjones879@gmail.com> Reviewed-by: Rostislav Pehlivanov <atomnuker@gmail.com>
* vorbisenc: Fix memory leak on errorsTyler Jones2017-06-06
| | | | | | | | | | Switches temporary samples for processing to be stored in the encoder's context, avoids memory leaks if any errors occur while encoding a frame. Fixes CID1412026 Signed-off-by: Tyler Jones <tdjones879@gmail.com> Reviewed-by: Rostislav Pehlivanov <atomnuker@gmail.com>
* vorbisenc: signal samples to skipRostislav Pehlivanov2017-06-05
| | | | | | The encoder never actually signalled how many samples to skip. Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
* avcodec/vorbisenc: Use a bufqueue in encoding with smaller lengthsTyler Jones2017-06-05
| | | | | | Switching the vorbis encoder to use a buffer queue for input frames allows saving lookahead samples more easily and safely for psychoacoustic systems, requiring less pointer arithmetic in the case of transient windows.
* avcodec/vorbisenc: Include bufqueue and afqueueTyler Jones2017-06-05
|
* avcodec/vorbisenc: Use fdsp for applying windowsTyler Jones2017-06-05
| | | | | | | Using fdsp improves readability and allows using architecture-specific optimizations. Signed-off-by: Tyler Jones <tdjones879@gmail.com>
* avcodec/vorbisenc: Include fdspTyler Jones2017-06-05
| | | | Signed-off-by: Tyler Jones <tdjones879@gmail.com>
* Merge commit 'def97856de6021965db86c25a732d78689bd6bb0'Michael Niedermayer2015-07-27
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * commit 'def97856de6021965db86c25a732d78689bd6bb0': lavc: AV-prefix all codec capabilities Conflicts: cmdutils.c ffmpeg.c ffplay.c libavcodec/8svx.c libavcodec/aacenc.c libavcodec/ac3dec.c libavcodec/adpcm.c libavcodec/alac.c libavcodec/atrac3plusdec.c libavcodec/bink.c libavcodec/dnxhddec.c libavcodec/dvdec.c libavcodec/dvenc.c libavcodec/ffv1dec.c libavcodec/ffv1enc.c libavcodec/fic.c libavcodec/flacdec.c libavcodec/flacenc.c libavcodec/flvdec.c libavcodec/fraps.c libavcodec/frwu.c libavcodec/gifdec.c libavcodec/h261dec.c libavcodec/hevc.c libavcodec/iff.c libavcodec/imc.c libavcodec/libopenjpegdec.c libavcodec/libvo-aacenc.c libavcodec/libvorbisenc.c libavcodec/libvpxdec.c libavcodec/libvpxenc.c libavcodec/libx264.c libavcodec/mjpegbdec.c libavcodec/mjpegdec.c libavcodec/mpegaudiodec_float.c libavcodec/msmpeg4dec.c libavcodec/mxpegdec.c libavcodec/nvenc_h264.c libavcodec/nvenc_hevc.c libavcodec/pngdec.c libavcodec/qpeg.c libavcodec/ra288.c libavcodec/rv10.c libavcodec/s302m.c libavcodec/sp5xdec.c libavcodec/takdec.c libavcodec/tiff.c libavcodec/tta.c libavcodec/utils.c libavcodec/v210dec.c libavcodec/vp6.c libavcodec/vp9.c libavcodec/wavpack.c libavcodec/yop.c Merged-by: Michael Niedermayer <michael@niedermayer.cc>
| * lavc: AV-prefix all codec capabilitiesVittorio Giovara2015-07-27
| | | | | | | | | | | | Express bitfields more simply. Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
* | Merge commit '7c6eb0a1b7bf1aac7f033a7ec6d8cacc3b5c2615'Michael Niedermayer2015-07-27
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * commit '7c6eb0a1b7bf1aac7f033a7ec6d8cacc3b5c2615': lavc: AV-prefix all codec flags Conflicts: doc/examples/muxing.c ffmpeg.c ffmpeg_opt.c ffplay.c libavcodec/aacdec.c libavcodec/aacenc.c libavcodec/ac3dec.c libavcodec/ac3enc_float.c libavcodec/atrac1.c libavcodec/atrac3.c libavcodec/atrac3plusdec.c libavcodec/dcadec.c libavcodec/ffv1enc.c libavcodec/h264.c libavcodec/h264_loopfilter.c libavcodec/h264_mb.c libavcodec/imc.c libavcodec/libmp3lame.c libavcodec/libtheoraenc.c libavcodec/libtwolame.c libavcodec/libvpxenc.c libavcodec/libxavs.c libavcodec/libxvid.c libavcodec/mpeg12dec.c libavcodec/mpeg12enc.c libavcodec/mpegaudiodec_template.c libavcodec/mpegvideo.c libavcodec/mpegvideo_enc.c libavcodec/mpegvideo_motion.c libavcodec/nellymoserdec.c libavcodec/nellymoserenc.c libavcodec/nvenc.c libavcodec/on2avc.c libavcodec/options_table.h libavcodec/opus_celt.c libavcodec/pngenc.c libavcodec/ra288.c libavcodec/ratecontrol.c libavcodec/twinvq.c libavcodec/vc1_block.c libavcodec/vc1_loopfilter.c libavcodec/vc1_mc.c libavcodec/vc1dec.c libavcodec/vorbisdec.c libavcodec/vp3.c libavcodec/wma.c libavcodec/wmaprodec.c libavcodec/x86/hpeldsp_init.c libavcodec/x86/me_cmp_init.c Merged-by: Michael Niedermayer <michael@niedermayer.cc>
| * lavc: AV-prefix all codec flagsVittorio Giovara2015-07-27
| | | | | | | | | | | | Convert doxygen to multiline and express bitfields more simply. Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
* | avcodec: Add a min size parameter to ff_alloc_packet2()Michael Niedermayer2015-07-27
| | | | | | | | | | | | | | | | This parameter can be used to inform the allocation code about how much downsizing might occur, and can be used to optimize how to allocate the packet Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | Merge commit '7f9f771eac0d37a632e0ed9bd89961d57fcfb7e0'Michael Niedermayer2015-02-14
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * commit '7f9f771eac0d37a632e0ed9bd89961d57fcfb7e0': avcodec: Don't anonymously typedef structs Conflicts: libavcodec/alac.c libavcodec/cinepak.c libavcodec/cscd.c libavcodec/dcadec.c libavcodec/g723_1.c libavcodec/gif.c libavcodec/iff.c libavcodec/kgv1dec.c libavcodec/libopenjpegenc.c libavcodec/libspeexenc.c libavcodec/ra288.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * avcodec: Don't anonymously typedef structsDiego Biurrun2015-02-14
| |
* | Merge commit '5aa710f46119bb9c1c38542f80f5338eb8b5ffb2'Michael Niedermayer2014-11-13
|\| | | | | | | | | | | | | | | | | | | | | * commit '5aa710f46119bb9c1c38542f80f5338eb8b5ffb2': vorbisenc: add missing parenthesis Conflicts: libavcodec/vorbisenc.c See: f72b735d41f9591452d2efe0987040462b409c2d Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * vorbisenc: add missing parenthesisVittorio Giovara2014-11-13
| | | | | | | | Bug-Id: CID 1238791
* | vorbisenc: avoid large stack allocation.Reimar Döffinger2014-09-03
| | | | | | | | | | | | | | Code is only used during initialization, so malloc/free should be fine to use. Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
* | avcodec/vorbisenc: use av_malloc(z)_array()Michael Niedermayer2014-08-25
| | | | | | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | Merge remote-tracking branch 'qatar/master'Michael Niedermayer2014-03-04
|\| | | | | | | | | | | | | | | | | | | * qatar/master: put_bits: Remove unused includes Conflicts: libavcodec/put_bits.h Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * put_bits: Remove unused includesVittorio Giovara2014-03-04
| | | | | | | | | | This requires adding includes to other files that relied on these being included implicitly.
* | Merge commit 'b2bed9325dbd6be0da1d91ffed3f513c40274fd2'Michael Niedermayer2013-10-04
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * commit 'b2bed9325dbd6be0da1d91ffed3f513c40274fd2': cosmetics: Group .name and .long_name together in codec/format declarations Conflicts: libavcodec/8svx.c libavcodec/alac.c libavcodec/cljr.c libavcodec/dnxhddec.c libavcodec/dnxhdenc.c libavcodec/dpxenc.c libavcodec/dvdec.c libavcodec/dvdsubdec.c libavcodec/dvdsubenc.c libavcodec/ffv1dec.c libavcodec/flacdec.c libavcodec/flvdec.c libavcodec/fraps.c libavcodec/frwu.c libavcodec/g726.c libavcodec/gif.c libavcodec/gifdec.c libavcodec/h261dec.c libavcodec/h263dec.c libavcodec/iff.c libavcodec/imc.c libavcodec/libopencore-amr.c libavcodec/libopenjpegdec.c libavcodec/libopenjpegenc.c libavcodec/libspeexenc.c libavcodec/libvo-amrwbenc.c libavcodec/libvorbisenc.c libavcodec/libvpxenc.c libavcodec/libx264.c libavcodec/libxavs.c libavcodec/libxvid.c libavcodec/ljpegenc.c libavcodec/mjpegbdec.c libavcodec/mjpegdec.c libavcodec/mpeg12dec.c libavcodec/mpeg4videodec.c libavcodec/msmpeg4dec.c libavcodec/pgssubdec.c libavcodec/pngdec.c libavcodec/pngenc.c libavcodec/proresdec_lgpl.c libavcodec/proresenc_kostya.c libavcodec/ra144enc.c libavcodec/rawdec.c libavcodec/rv10.c libavcodec/sp5xdec.c libavcodec/takdec.c libavcodec/tta.c libavcodec/v210dec.c libavcodec/vp6.c libavcodec/wavpack.c libavcodec/xbmenc.c libavcodec/yop.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * cosmetics: Group .name and .long_name together in codec/format declarationsDiego Biurrun2013-10-03
| |
* | avcodec/vorbisenc: change 6 asserts to av_asserts()Michael Niedermayer2013-07-27
| | | | | | | | | | | | speed relevant ones use av_assert2() Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | Merge commit '4a2ef39442bf7f0150db07a1fbfcf8286e4d44a3'Michael Niedermayer2013-07-26
|\| | | | | | | | | | | | | | | | | | | * commit '4a2ef39442bf7f0150db07a1fbfcf8286e4d44a3': cosmetics: Add '0' to float constants ending in '.'. Conflicts: libavcodec/ra288.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * cosmetics: Add '0' to float constants ending in '.'.Diego Biurrun2013-07-25
| |
* | Merge commit '0f24a3ca999a702f83af9307f9f47b6fdeb546a5'Michael Niedermayer2013-03-12
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * commit '0f24a3ca999a702f83af9307f9f47b6fdeb546a5': lavc: remove disabled FF_API_OLD_ENCODE_VIDEO cruft lavc: remove disabled FF_API_OLD_ENCODE_AUDIO cruft lavc: remove disabled FF_API_OLD_DECODE_AUDIO cruft Conflicts: libavcodec/flacenc.c libavcodec/libgsm.c libavcodec/utils.c libavcodec/version.h The compatibility wrapers are left as they likely sre still in wide use. They will be removed when they break or otherwise cause work without an volunteer being available. Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * lavc: remove disabled FF_API_OLD_ENCODE_AUDIO cruftAnton Khirnov2013-03-09
| |
* | normalize calls to ff_alloc_packet2James Zern2013-03-06
| | | | | | | | | | | | | | - check ret < 0 - remove excessive error log Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | Merge commit 'c242bbd8b6939507a1a6fb64101b0553d92d303f'Michael Niedermayer2013-02-26
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * commit 'c242bbd8b6939507a1a6fb64101b0553d92d303f': Remove unnecessary dsputil.h #includes Conflicts: libavcodec/ffv1.c libavcodec/h261dec.c libavcodec/h261enc.c libavcodec/h264pred.c libavcodec/lpc.h libavcodec/mjpegdec.c libavcodec/rectangle.h libavcodec/x86/idct_sse2_xvid.c Merged-by: Michael Niedermayer <michaelni@gmx.at>