Commit Graph

13 Commits

Author SHA1 Message Date
James Almer a5bfced3a6 avcodec/encode: add missing assert to avcodec_receive_packet()
Encoders must return reference counted packets.

This was checked only for encoders using the AVCodec->encode2() API, while
blindly accepting whatever encoders using the AVCodec->receive_packet() API
were returning.

Signed-off-by: James Almer <jamrial@gmail.com>
2019-11-14 12:30:51 -03:00
Marton Balint ca13bf73ab avcodec/encode: only allow undersized audio frames if they are the last
Otherwise the user might get a silence padded frame in the beginning or in the
middle of the encoding.

Some other bug uncovered this:

./ffmpeg -loglevel verbose -y -f data -i /dev/zero \
-filter_complex "nullsrc=s=60x60:d=10[v0];sine=d=10[a]" \
-map '[v0]' -c:v:0 rawvideo \
-map '[a]'  -c:a:0 mp2 \
-f mpegts out.ts

Signed-off-by: Marton Balint <cus@passwd.hu>
2019-08-11 22:32:42 +02:00
Zhong Li 9d50474056 lavc/encode: fix frame_number double-counted
Encoder frame_number may be double-counted if some frames are cached and then flushed.
Take qsv encoder (some frames are cached firsty for asynchronism) as example,
./ffmpeg -loglevel verbose -hwaccel qsv -c:v h264_qsv -i in.mp4 -vframes 100 -c:v h264_qsv out.mp4
frame_number passed to encoder is double-counted and larger than the accurate value.
Libx264 encoding with B frames can also reproduce it.

Signed-off-by: Zhong Li <zhong.li@intel.com>
2018-08-27 16:54:40 +08:00
Jun Zhao 0f9c71b7c9 lavc/encode: remove redundant av_init_packet after av_packet_unref.
remove redundant av_init_packet after av_packet_unref.
av_packet_unref have call av_init_packet and reset the packet size.

Signed-off-by: Jun Zhao <mypopydev@gmail.com>
2018-08-23 19:17:16 +08:00
James Almer 10850f68e8 avcodec/encode: use av_packet_make_refcounted to ensure packets are ref counted
Simplifies code.

Signed-off-by: James Almer <jamrial@gmail.com>
2018-04-01 23:40:42 -03:00
James Almer 0f1f0afe7d Merge commit '3bf67779de608d5e132546f4a46cb9f021bb7305'
* commit '3bf67779de608d5e132546f4a46cb9f021bb7305':
  lavc: Drop deprecated way of setting audio delay on encode

Merged-by: James Almer <jamrial@gmail.com>
2017-10-23 16:38:04 -03:00
James Almer 649c851900 avcodec/encode: do proper cleanup on failure
Fixes the last remaining memleaks introduced by a58f8cc983.

Signed-off-by: James Almer <jamrial@gmail.com>
2017-10-03 14:00:27 -03:00
James Almer 3029c9c421 avcodec/encode: free non-referenced packets' side data in the old encode API functions
Fixes memleaks introduced by a58f8cc983.
2017-10-02 18:58:53 -03:00
James Almer a58f8cc983 avcodec/encode: remove usage of av_dup_packet()
Reviewed-by: wm4 <nfxjfg@googlemail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2017-10-02 11:14:57 -03:00
Muhammad Faiz 17bfae9252 avcodec: do not use AVFrame accessor
Reviewed-by: wm4 <nfxjfg@googlemail.com>
Signed-off-by: Muhammad Faiz <mfcc64@gmail.com>
2017-04-23 14:27:47 +07:00
James Almer 6cdb49f35c Merge commit '319cd8654d71f5aef953f36190756cd2eb8c3d24'
* commit '319cd8654d71f5aef953f36190756cd2eb8c3d24':
  lavc: move encoding-related code from utils.c to a new file

Merged-by: James Almer <jamrial@gmail.com>
2017-04-07 00:42:38 -03:00
Vittorio Giovara 3bf67779de lavc: Drop deprecated way of setting audio delay on encode
Deprecated in 08/2014.
2017-03-23 10:09:16 +01:00
Anton Khirnov 319cd8654d lavc: move encoding-related code from utils.c to a new file 2016-11-29 10:39:20 +01:00