From patchwork Sun Apr 5 23:38:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 18693 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 406F244AE07 for ; Mon, 6 Apr 2020 02:38:41 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2510868B1B9; Mon, 6 Apr 2020 02:38:41 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 148C968B1AF for ; Mon, 6 Apr 2020 02:38:35 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id CE2CFE2130; Mon, 6 Apr 2020 01:38:34 +0200 (CEST) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id IAsVlAdCUaFu; Mon, 6 Apr 2020 01:38:32 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id E5B6DE346B; Mon, 6 Apr 2020 01:38:30 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Mon, 6 Apr 2020 01:38:24 +0200 Message-Id: <20200405233824.29682-3-cus@passwd.hu> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20200405233824.29682-1-cus@passwd.hu> References: <20200405233824.29682-1-cus@passwd.hu> Subject: [FFmpeg-devel] [PATCH 3/3] avformat: deprecate muxing uncoded frames X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Marton Balint MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" The same goal can be achieved using the WRAPPED_AVFRAME codec with the existing API. Signed-off-by: Marton Balint --- doc/APIchanges | 4 ++++ libavdevice/alsa_enc.c | 4 ++++ libavdevice/opengl_enc.c | 4 ++++ libavdevice/pulse_audio_enc.c | 4 ++++ libavdevice/version.h | 4 ++-- libavdevice/xv.c | 4 ++++ libavformat/avformat.h | 7 +++++++ libavformat/internal.h | 2 ++ libavformat/mux.c | 16 ++++++++++++++++ libavformat/uncodedframecrcenc.c | 6 ++++++ libavformat/version.h | 6 +++++- 11 files changed, 58 insertions(+), 3 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index f1d7eac2ee..57d4fdc609 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -15,6 +15,10 @@ libavutil: 2017-10-21 API changes, most recent first: +2020-04-xx - xxxxxxxxxx - lavf 58.43.100 - avformat.h + Deprecate av_interleaved_write_uncoded_frame(), av_write_uncoded_frame() and + av_write_uncoded_frame_query(). + 2020-03-29 - xxxxxxxxxx - lavf 58.42.100 - avformat.h av_read_frame() now guarantees to handle uninitialized input packets and to return refcounted packets on success. diff --git a/libavdevice/alsa_enc.c b/libavdevice/alsa_enc.c index 1a6d01e3b1..80c9c509e2 100644 --- a/libavdevice/alsa_enc.c +++ b/libavdevice/alsa_enc.c @@ -116,6 +116,7 @@ static int audio_write_packet(AVFormatContext *s1, AVPacket *pkt) return 0; } +#if FF_API_UNCODED_FRAME static int audio_write_frame(AVFormatContext *s1, int stream_index, AVFrame **frame, unsigned flags) { @@ -133,6 +134,7 @@ static int audio_write_frame(AVFormatContext *s1, int stream_index, pkt.duration = (*frame)->pkt_duration; return audio_write_packet(s1, &pkt); } +#endif static void audio_get_output_timestamp(AVFormatContext *s1, int stream, @@ -166,7 +168,9 @@ AVOutputFormat ff_alsa_muxer = { .write_header = audio_write_header, .write_packet = audio_write_packet, .write_trailer = ff_alsa_close, +#if FF_API_UNCODED_FRAME .write_uncoded_frame = audio_write_frame, +#endif .get_device_list = audio_get_device_list, .get_output_timestamp = audio_get_output_timestamp, .flags = AVFMT_NOFILE, diff --git a/libavdevice/opengl_enc.c b/libavdevice/opengl_enc.c index b8bc46ebb5..a829f9ccb2 100644 --- a/libavdevice/opengl_enc.c +++ b/libavdevice/opengl_enc.c @@ -1225,6 +1225,7 @@ static int opengl_write_packet(AVFormatContext *h, AVPacket *pkt) return opengl_draw(h, frame, 0); } +#if FF_API_UNCODED_FRAME static int opengl_write_frame(AVFormatContext *h, int stream_index, AVFrame **frame, unsigned flags) { @@ -1232,6 +1233,7 @@ static int opengl_write_frame(AVFormatContext *h, int stream_index, return 0; return opengl_draw(h, *frame, 0); } +#endif #define OFFSET(x) offsetof(OpenGLContext, x) #define ENC AV_OPT_FLAG_ENCODING_PARAM @@ -1259,7 +1261,9 @@ AVOutputFormat ff_opengl_muxer = { .video_codec = AV_CODEC_ID_WRAPPED_AVFRAME, .write_header = opengl_write_header, .write_packet = opengl_write_packet, +#if FF_API_UNCODED_FRAME .write_uncoded_frame = opengl_write_frame, +#endif .write_trailer = opengl_write_trailer, .control_message = opengl_control_message, .flags = AVFMT_NOFILE | AVFMT_VARIABLE_FPS | AVFMT_NOTIMESTAMPS, diff --git a/libavdevice/pulse_audio_enc.c b/libavdevice/pulse_audio_enc.c index e0a631b227..0b56984ec4 100644 --- a/libavdevice/pulse_audio_enc.c +++ b/libavdevice/pulse_audio_enc.c @@ -670,6 +670,7 @@ static int pulse_write_packet(AVFormatContext *h, AVPacket *pkt) return AVERROR_EXTERNAL; } +#if FF_API_UNCODED_FRAME static int pulse_write_frame(AVFormatContext *h, int stream_index, AVFrame **frame, unsigned flags) { @@ -686,6 +687,7 @@ static int pulse_write_frame(AVFormatContext *h, int stream_index, pkt.duration = (*frame)->pkt_duration; return pulse_write_packet(h, &pkt); } +#endif static void pulse_get_output_timestamp(AVFormatContext *h, int stream, int64_t *dts, int64_t *wall) @@ -786,7 +788,9 @@ AVOutputFormat ff_pulse_muxer = { .video_codec = AV_CODEC_ID_NONE, .write_header = pulse_write_header, .write_packet = pulse_write_packet, +#if FF_API_UNCODED_FRAME .write_uncoded_frame = pulse_write_frame, +#endif .write_trailer = pulse_write_trailer, .get_output_timestamp = pulse_get_output_timestamp, .get_device_list = pulse_get_device_list, diff --git a/libavdevice/version.h b/libavdevice/version.h index 10717564e9..9ee3d3db4a 100644 --- a/libavdevice/version.h +++ b/libavdevice/version.h @@ -28,8 +28,8 @@ #include "libavutil/version.h" #define LIBAVDEVICE_VERSION_MAJOR 58 -#define LIBAVDEVICE_VERSION_MINOR 9 -#define LIBAVDEVICE_VERSION_MICRO 103 +#define LIBAVDEVICE_VERSION_MINOR 10 +#define LIBAVDEVICE_VERSION_MICRO 100 #define LIBAVDEVICE_VERSION_INT AV_VERSION_INT(LIBAVDEVICE_VERSION_MAJOR, \ LIBAVDEVICE_VERSION_MINOR, \ diff --git a/libavdevice/xv.c b/libavdevice/xv.c index 2c5f1a4432..67e1530199 100644 --- a/libavdevice/xv.c +++ b/libavdevice/xv.c @@ -325,6 +325,7 @@ static int xv_write_packet(AVFormatContext *s, AVPacket *pkt) return write_picture(s, frame->data, frame->linesize); } +#if FF_API_UNCODED_FRAME static int xv_write_frame(AVFormatContext *s, int stream_index, AVFrame **frame, unsigned flags) { @@ -333,6 +334,7 @@ static int xv_write_frame(AVFormatContext *s, int stream_index, AVFrame **frame, return 0; return write_picture(s, (*frame)->data, (*frame)->linesize); } +#endif static int xv_control_message(AVFormatContext *s, int type, void *data, size_t data_size) { @@ -373,7 +375,9 @@ AVOutputFormat ff_xv_muxer = { .video_codec = AV_CODEC_ID_WRAPPED_AVFRAME, .write_header = xv_write_header, .write_packet = xv_write_packet, +#if FF_API_UNCODED_FRAME .write_uncoded_frame = xv_write_frame, +#endif .write_trailer = xv_write_trailer, .control_message = xv_control_message, .flags = AVFMT_NOFILE | AVFMT_VARIABLE_FPS | AVFMT_NOTIMESTAMPS, diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 39b99b4481..c7dd35f714 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -573,6 +573,7 @@ typedef struct AVOutputFormat { int (*control_message)(struct AVFormatContext *s, int type, void *data, size_t data_size); +#if FF_API_UNCODED_FRAME /** * Write an uncoded AVFrame. * @@ -583,6 +584,7 @@ typedef struct AVOutputFormat { */ int (*write_uncoded_frame)(struct AVFormatContext *, int stream_index, AVFrame **frame, unsigned flags); +#endif /** * Returns device list with it properties. * @see avdevice_list_devices() for more details. @@ -2636,6 +2638,7 @@ int av_write_frame(AVFormatContext *s, AVPacket *pkt); */ int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt); +#if FF_API_UNCODED_FRAME /** * Write an uncoded frame to an output media file. * @@ -2644,6 +2647,7 @@ int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt); * * See av_interleaved_write_uncoded_frame() for details. */ +attribute_deprecated int av_write_uncoded_frame(AVFormatContext *s, int stream_index, AVFrame *frame); @@ -2663,6 +2667,7 @@ int av_write_uncoded_frame(AVFormatContext *s, int stream_index, * * @return >=0 for success, a negative code on error */ +attribute_deprecated int av_interleaved_write_uncoded_frame(AVFormatContext *s, int stream_index, AVFrame *frame); @@ -2672,7 +2677,9 @@ int av_interleaved_write_uncoded_frame(AVFormatContext *s, int stream_index, * @return >=0 if an uncoded frame can be written to that muxer and stream, * <0 if not */ +attribute_deprecated int av_write_uncoded_frame_query(AVFormatContext *s, int stream_index); +#endif /** * Write the stream trailer to an output media file and free the diff --git a/libavformat/internal.h b/libavformat/internal.h index 332477a532..6b16a36a73 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -618,6 +618,7 @@ int ff_rfps_add_frame(AVFormatContext *ic, AVStream *st, int64_t dts); void ff_rfps_calculate(AVFormatContext *ic); +#if FF_API_UNCODED_FRAME /** * Flags for AVFormatContext.write_uncoded_frame() */ @@ -630,6 +631,7 @@ enum AVWriteUncodedFrameFlags { AV_WRITE_UNCODED_FRAME_QUERY = 0x0001, }; +#endif /** * Copies the whilelists from one context to the other diff --git a/libavformat/mux.c b/libavformat/mux.c index cc2d1e275a..26af5c5030 100644 --- a/libavformat/mux.c +++ b/libavformat/mux.c @@ -548,6 +548,7 @@ fail: return ret; } +#if FF_API_UNCODED_FRAME #define AV_PKT_FLAG_UNCODED_FRAME 0x2000 /* Note: using sizeof(AVFrame) from outside lavu is unsafe in general, but @@ -555,6 +556,7 @@ fail: The value is chosen to be very unlikely to appear on its own and to cause immediate failure if used anywhere as a real size. */ #define UNCODED_FRAME_PACKET_SIZE (INT_MIN / 3 * 2 + (int)sizeof(AVFrame)) +#endif #if FF_API_COMPUTE_PKT_FIELDS2 && FF_API_LAVF_AVCTX @@ -649,8 +651,12 @@ static int compute_muxer_pkt_fields(AVFormatContext *s, AVStream *st, AVPacket * /* update pts */ switch (st->codecpar->codec_type) { case AVMEDIA_TYPE_AUDIO: +#if FF_API_UNCODED_FRAME frame_size = (pkt->flags & AV_PKT_FLAG_UNCODED_FRAME) ? ((AVFrame *)pkt->data)->nb_samples : +#else + frame_size = +#endif av_get_audio_frame_duration(st->codec, pkt->size); /* HACK/FIXME, we skip the initial 0 size packets as they are most @@ -745,12 +751,16 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt) } } +#if FF_API_UNCODED_FRAME if ((pkt->flags & AV_PKT_FLAG_UNCODED_FRAME)) { AVFrame *frame = (AVFrame *)pkt->data; av_assert0(pkt->size == UNCODED_FRAME_PACKET_SIZE); ret = s->oformat->write_uncoded_frame(s, pkt->stream_index, &frame, 0); av_frame_free(&frame); } else { +#else + { +#endif ret = s->oformat->write_packet(s, pkt); } @@ -926,10 +936,14 @@ int ff_interleave_add_packet(AVFormatContext *s, AVPacket *pkt, this_pktl = av_malloc(sizeof(AVPacketList)); if (!this_pktl) return AVERROR(ENOMEM); +#if FF_API_UNCODED_FRAME if (pkt->flags & AV_PKT_FLAG_UNCODED_FRAME) { av_assert0(pkt->size == UNCODED_FRAME_PACKET_SIZE); av_assert0(((AVFrame *)pkt->data)->buf); } else { +#else + { +#endif if ((ret = av_packet_make_refcounted(pkt)) < 0) { av_free(this_pktl); return ret; @@ -1319,6 +1333,7 @@ int ff_write_chained(AVFormatContext *dst, int dst_stream, AVPacket *pkt, return ret; } +#if FF_API_UNCODED_FRAME static int write_uncoded_frame_internal(AVFormatContext *s, int stream_index, AVFrame *frame, int interleaved) { @@ -1366,3 +1381,4 @@ int av_write_uncoded_frame_query(AVFormatContext *s, int stream_index) return s->oformat->write_uncoded_frame(s, stream_index, NULL, AV_WRITE_UNCODED_FRAME_QUERY); } +#endif diff --git a/libavformat/uncodedframecrcenc.c b/libavformat/uncodedframecrcenc.c index 2f1a14ca97..6d6b1397b1 100644 --- a/libavformat/uncodedframecrcenc.c +++ b/libavformat/uncodedframecrcenc.c @@ -26,6 +26,7 @@ #include "avformat.h" #include "internal.h" +#if FF_API_UNCODED_FRAME /* Identical to Adler32 when the type is uint8_t. */ #define DEFINE_CKSUM_LINE(name, type, conv) \ static void cksum_line_ ## name(unsigned *cksum, void *data, unsigned size) \ @@ -118,12 +119,14 @@ static void audio_frame_cksum(AVBPrint *bp, AVFrame *frame) av_bprintf(bp, ", 0x%08"PRIx32, cksum); } } +#endif static int write_header(struct AVFormatContext *s) { return ff_framehash_write_header(s); } +#if FF_API_UNCODED_FRAME static int write_frame(struct AVFormatContext *s, int stream_index, AVFrame **frame, unsigned flags) { @@ -158,6 +161,7 @@ static int write_frame(struct AVFormatContext *s, int stream_index, av_bprint_finalize(&bp, NULL); return ret; } +#endif static int write_packet(struct AVFormatContext *s, AVPacket *pkt) { @@ -171,7 +175,9 @@ AVOutputFormat ff_uncodedframecrc_muxer = { .video_codec = AV_CODEC_ID_RAWVIDEO, .write_header = write_header, .write_packet = write_packet, +#if FF_API_UNCODED_FRAME .write_uncoded_frame = write_frame, +#endif .flags = AVFMT_VARIABLE_FPS | AVFMT_TS_NONSTRICT | AVFMT_TS_NEGATIVE, }; diff --git a/libavformat/version.h b/libavformat/version.h index 18c2f5fec2..80bb0e9d1d 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -32,7 +32,7 @@ // Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium) // Also please add any ticket numbers that you believe might be affected here #define LIBAVFORMAT_VERSION_MAJOR 58 -#define LIBAVFORMAT_VERSION_MINOR 42 +#define LIBAVFORMAT_VERSION_MINOR 43 #define LIBAVFORMAT_VERSION_MICRO 100 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ @@ -106,6 +106,10 @@ #ifndef FF_API_AVIOFORMAT #define FF_API_AVIOFORMAT (LIBAVFORMAT_VERSION_MAJOR < 59) #endif +#ifndef FF_API_UNCODED_FRAME +#define FF_API_UNCODED_FRAME (LIBAVFORMAT_VERSION_MAJOR < 59) +#endif + #ifndef FF_API_R_FRAME_RATE