Commit Graph

13 Commits

Author SHA1 Message Date
James Almer
73ee53f317 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
686755f02b 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✌️0 rawvideo \
-map '[a]'  -c🅰️0 mp2 \
-f mpegts out.ts

Signed-off-by: Marton Balint <cus@passwd.hu>
2019-08-11 22:32:42 +02:00
Zhong Li
d91370e0f1 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
c9ed7f0024 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
e61d8b82a2 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
d2484639bc Merge commit '48bb0da050329e5111b00a12dfc154b7e78fb3a3'
* commit '48bb0da050329e5111b00a12dfc154b7e78fb3a3':
  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
87e625c263 avcodec/encode: do proper cleanup on failure
Fixes the last remaining memleaks introduced by a22c6a4796.

Signed-off-by: James Almer <jamrial@gmail.com>
2017-10-03 14:00:27 -03:00
James Almer
712ee85816 avcodec/encode: free non-referenced packets' side data in the old encode API functions
Fixes memleaks introduced by a22c6a4796.
2017-10-02 18:58:53 -03:00
James Almer
a22c6a4796 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
31f61b0d4f 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
bd9057e74b Merge commit '328cd2b599bc2d0d38f3c12606fa2a66eeec016e'
* commit '328cd2b599bc2d0d38f3c12606fa2a66eeec016e':
  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
48bb0da050 lavc: Drop deprecated way of setting audio delay on encode
Deprecated in 08/2014.
2017-03-23 10:09:16 +01:00
Anton Khirnov
328cd2b599 lavc: move encoding-related code from utils.c to a new file 2016-11-29 10:39:20 +01:00