[FFmpeg-devel] [PATCH 2/5] ffmpeg: use the write_uncoded_frame() API.
Michael Niedermayer
michaelni at gmx.at
Thu Jan 16 05:32:11 CET 2014
On Wed, Jan 15, 2014 at 11:30:01PM +0100, Nicolas George wrote:
> Signed-off-by: Nicolas George <george at nsup.org>
> ---
> ffmpeg.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++---------
> ffmpeg.h | 1 +
> 2 files changed, 55 insertions(+), 9 deletions(-)
>
>
> Fixed: the previous patch did call the non-interleaved version.
>
> Change: use a different magic constant for the packet size.
>
>
> diff --git a/ffmpeg.c b/ffmpeg.c
> index 5ccbf10..f998808 100644
> --- a/ffmpeg.c
> +++ b/ffmpeg.c
> @@ -163,6 +163,9 @@ static struct termios oldtty;
> static int restore_tty;
> #endif
>
> +/* Use a different value than the library. */
> +#define UNCODED_FRAME_PACKET_SIZE (INT_MIN / 3 * 2 - (int)sizeof(AVFrame))
> +
> static void free_input_threads(void);
>
>
> @@ -644,7 +647,23 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost)
> );
> }
>
> - ret = av_interleaved_write_frame(s, pkt);
> + if (ost->uncoded_frame) {
> + AVFrame *frame = av_frame_clone((AVFrame *)pkt->data);
> + av_assert0(!ost->encoding_needed);
> + av_assert0(pkt->size == UNCODED_FRAME_PACKET_SIZE);
the asserts should be before the clone, i think
> + if (!frame) {
> + ret = AVERROR(ENOMEM);
> + } else {
> + frame->pts = frame->pkt_pts = pkt->pts;
> + frame->pkt_dts = pkt->dts;
> + av_frame_set_pkt_duration(frame, pkt->duration);
> + ret = av_interleaved_write_uncoded_frame(s, pkt->stream_index, frame);
> + pkt->size = 0;
> + pkt->data = NULL;
> + }
> + } else {
> + ret = av_interleaved_write_frame(s, pkt);
> + }
looking at this i wonder if this frame->packet change would not be
simpler if its done by the raw video encoder. (or a seperate
uncoded frame in packet encoder)
It would avoid complexity on the user application side except
the need to tell the encoder that it can return AVFrame in AVPacket
packets
The individual muxers would stay as they are in your patch and
av_interleaved_write_frame() would accept these
AVFrame in AVPacket packets from the encoder
the patch should be ok though if above has some issues / is worse
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Many that live deserve death. And some that die deserve life. Can you give
it to them? Then do not be too eager to deal out death in judgement. For
even the very wise cannot see all ends. -- Gandalf
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140116/7203515c/attachment.asc>
More information about the ffmpeg-devel
mailing list