[FFmpeg-devel] [PATCH 1/8] avcodec/jpeglsenc: Don't use put bits API for byte-aligned writes

Paul B Mahol onemda at gmail.com
Sun Sep 6 20:09:53 EEST 2020


On Sat, Sep 05, 2020 at 01:17:09AM +0200, Andreas Rheinhardt wrote:
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
> ---
> Is it actually guaranteed that the allocated packet size is
> sufficient? If it is, one could use unchecked writes throughout; if it
> isn't, should I add a check to properly error out in case the buffer is
> too small? (And what would the return value be in this case?)
> 
>  libavcodec/jpeglsenc.c       | 80 +++++++++++++++++++++---------------
>  libavcodec/mjpegenc.h        |  6 ---
>  libavcodec/mjpegenc_common.c |  6 +++
>  3 files changed, 52 insertions(+), 40 deletions(-)
> 

lgtm.

Packet size may be smaller than needed, if there is no check it will fail.

Usually it is allocated to max possible encoded packet size.

Can not be sure, need to try encoding special pixels combinations that
never happen in reality (almost).

Ultimately some codecs check if encoded packet gonna exceed uncompressed
frame than they just store uncompressed  and properly mark bitstream.
(Latest FFv1 encoder version, previous versions had this misfeature/bug)


More information about the ffmpeg-devel mailing list