From patchwork Sun Apr 5 23:38:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 18691 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 62B0D44AE07 for ; Mon, 6 Apr 2020 02:38:35 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3F90B68B128; Mon, 6 Apr 2020 02:38:35 +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 5932E6881AD for ; Mon, 6 Apr 2020 02:38:29 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 02221E31FD; Mon, 6 Apr 2020 01:38:29 +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 cDfLJrp1E3wp; Mon, 6 Apr 2020 01:38:27 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 9831FE2130; Mon, 6 Apr 2020 01:38:26 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Mon, 6 Apr 2020 01:38:22 +0200 Message-Id: <20200405233824.29682-1-cus@passwd.hu> X-Mailer: git-send-email 2.16.4 Subject: [FFmpeg-devel] [PATCH 1/3] avdevice/xv: change codec to wrapped avframe 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" Signed-off-by: Marton Balint --- libavdevice/xv.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/libavdevice/xv.c b/libavdevice/xv.c index c3ed2e48bd..2c5f1a4432 100644 --- a/libavdevice/xv.c +++ b/libavdevice/xv.c @@ -113,8 +113,8 @@ static int xv_write_header(AVFormatContext *s) if ( s->nb_streams > 1 || par->codec_type != AVMEDIA_TYPE_VIDEO - || par->codec_id != AV_CODEC_ID_RAWVIDEO) { - av_log(s, AV_LOG_ERROR, "Only supports one rawvideo stream\n"); + || par->codec_id != AV_CODEC_ID_WRAPPED_AVFRAME) { + av_log(s, AV_LOG_ERROR, "Only supports one wrapped avframe stream\n"); return AVERROR(EINVAL); } @@ -321,13 +321,8 @@ static int write_picture(AVFormatContext *s, uint8_t *input_data[4], static int xv_write_packet(AVFormatContext *s, AVPacket *pkt) { - AVCodecParameters *par = s->streams[0]->codecpar; - uint8_t *data[4]; - int linesize[4]; - - av_image_fill_arrays(data, linesize, pkt->data, par->format, - par->width, par->height, 1); - return write_picture(s, data, linesize); + AVFrame *frame = (AVFrame *)pkt->data; + return write_picture(s, frame->data, frame->linesize); } static int xv_write_frame(AVFormatContext *s, int stream_index, AVFrame **frame, @@ -375,7 +370,7 @@ AVOutputFormat ff_xv_muxer = { .long_name = NULL_IF_CONFIG_SMALL("XV (XVideo) output device"), .priv_data_size = sizeof(XVContext), .audio_codec = AV_CODEC_ID_NONE, - .video_codec = AV_CODEC_ID_RAWVIDEO, + .video_codec = AV_CODEC_ID_WRAPPED_AVFRAME, .write_header = xv_write_header, .write_packet = xv_write_packet, .write_uncoded_frame = xv_write_frame, From patchwork Sun Apr 5 23:38:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 18692 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 7B38C44AE07 for ; Mon, 6 Apr 2020 02:38:36 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 687E868B1AE; Mon, 6 Apr 2020 02:38:36 +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 A8D3068B1A9 for ; Mon, 6 Apr 2020 02:38:30 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 90811E3347; Mon, 6 Apr 2020 01:38:30 +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 AgFI34NY5N0a; Mon, 6 Apr 2020 01:38:29 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id ABD8AE346B; Mon, 6 Apr 2020 01:38:28 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Mon, 6 Apr 2020 01:38:23 +0200 Message-Id: <20200405233824.29682-2-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 2/3] avdevice/opengl: change codec to wrapped avframe 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" Signed-off-by: Marton Balint --- libavdevice/opengl_enc.c | 54 +++++++++--------------------------------------- 1 file changed, 10 insertions(+), 44 deletions(-) diff --git a/libavdevice/opengl_enc.c b/libavdevice/opengl_enc.c index ae03caa8c5..b8bc46ebb5 100644 --- a/libavdevice/opengl_enc.c +++ b/libavdevice/opengl_enc.c @@ -277,7 +277,7 @@ static const struct OpenGLFormatDesc { }; static av_cold int opengl_prepare_vertex(AVFormatContext *s); -static int opengl_draw(AVFormatContext *h, void *intput, int repaint, int is_pkt); +static int opengl_draw(AVFormatContext *h, void *intput, int repaint); static av_cold int opengl_init_context(OpenGLContext *opengl); static av_cold void opengl_deinit_context(OpenGLContext *opengl) @@ -320,7 +320,7 @@ static int opengl_resize(AVFormatContext *h, int width, int height) } if ((ret = opengl_prepare_vertex(h)) < 0) goto end; - ret = opengl_draw(h, NULL, 1, 0); + ret = opengl_draw(h, NULL, 1); } end: return ret; @@ -1060,8 +1060,8 @@ static av_cold int opengl_write_header(AVFormatContext *h) if (h->nb_streams != 1 || h->streams[0]->codecpar->codec_type != AVMEDIA_TYPE_VIDEO || - h->streams[0]->codecpar->codec_id != AV_CODEC_ID_RAWVIDEO) { - av_log(opengl, AV_LOG_ERROR, "Only a single video stream is supported.\n"); + h->streams[0]->codecpar->codec_id != AV_CODEC_ID_WRAPPED_AVFRAME) { + av_log(opengl, AV_LOG_ERROR, "Only a single wrapped avframe stream is supported.\n"); return AVERROR(EINVAL); } st = h->streams[0]; @@ -1124,35 +1124,6 @@ static av_cold int opengl_write_header(AVFormatContext *h) return ret; } -static uint8_t* opengl_get_plane_pointer(OpenGLContext *opengl, AVPacket *pkt, int comp_index, - const AVPixFmtDescriptor *desc) -{ - uint8_t *data = pkt->data; - int wordsize = opengl_type_size(opengl->type); - int width_chroma = AV_CEIL_RSHIFT(opengl->width, desc->log2_chroma_w); - int height_chroma = AV_CEIL_RSHIFT(opengl->height, desc->log2_chroma_h); - int plane = desc->comp[comp_index].plane; - - switch(plane) { - case 0: - break; - case 1: - data += opengl->width * opengl->height * wordsize; - break; - case 2: - data += opengl->width * opengl->height * wordsize; - data += width_chroma * height_chroma * wordsize; - break; - case 3: - data += opengl->width * opengl->height * wordsize; - data += 2 * width_chroma * height_chroma * wordsize; - break; - default: - return NULL; - } - return data; -} - #define LOAD_TEXTURE_DATA(comp_index, sub) \ { \ int width = sub ? AV_CEIL_RSHIFT(opengl->width, desc->log2_chroma_w) : opengl->width; \ @@ -1161,7 +1132,7 @@ static uint8_t* opengl_get_plane_pointer(OpenGLContext *opengl, AVPacket *pkt, i int plane = desc->comp[comp_index].plane; \ \ glBindTexture(GL_TEXTURE_2D, opengl->texture_name[comp_index]); \ - if (!is_pkt) { \ + { \ GLint length = ((AVFrame *)input)->linesize[plane]; \ int bytes_per_pixel = opengl_type_size(opengl->type); \ if (!(desc->flags & AV_PIX_FMT_FLAG_PLANAR)) \ @@ -1184,14 +1155,10 @@ static uint8_t* opengl_get_plane_pointer(OpenGLContext *opengl, AVPacket *pkt, i data += length; \ } \ } \ - } else { \ - data = opengl_get_plane_pointer(opengl, input, comp_index, desc); \ - glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, \ - opengl->format, opengl->type, data); \ } \ } -static int opengl_draw(AVFormatContext *h, void *input, int repaint, int is_pkt) +static int opengl_draw(AVFormatContext *h, void *input, int repaint) { OpenGLContext *opengl = h->priv_data; enum AVPixelFormat pix_fmt = h->streams[0]->codecpar->format; @@ -1211,8 +1178,6 @@ static int opengl_draw(AVFormatContext *h, void *input, int repaint, int is_pkt) glClear(GL_COLOR_BUFFER_BIT); if (!repaint) { - if (is_pkt) - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); LOAD_TEXTURE_DATA(0, 0) if (desc->flags & AV_PIX_FMT_FLAG_PLANAR) { LOAD_TEXTURE_DATA(1, 1) @@ -1256,7 +1221,8 @@ static int opengl_draw(AVFormatContext *h, void *input, int repaint, int is_pkt) static int opengl_write_packet(AVFormatContext *h, AVPacket *pkt) { - return opengl_draw(h, pkt, 0, 1); + AVFrame *frame = (AVFrame *)pkt->data; + return opengl_draw(h, frame, 0); } static int opengl_write_frame(AVFormatContext *h, int stream_index, @@ -1264,7 +1230,7 @@ static int opengl_write_frame(AVFormatContext *h, int stream_index, { if ((flags & AV_WRITE_UNCODED_FRAME_QUERY)) return 0; - return opengl_draw(h, *frame, 0, 0); + return opengl_draw(h, *frame, 0); } #define OFFSET(x) offsetof(OpenGLContext, x) @@ -1290,7 +1256,7 @@ AVOutputFormat ff_opengl_muxer = { .long_name = NULL_IF_CONFIG_SMALL("OpenGL output"), .priv_data_size = sizeof(OpenGLContext), .audio_codec = AV_CODEC_ID_NONE, - .video_codec = AV_CODEC_ID_RAWVIDEO, + .video_codec = AV_CODEC_ID_WRAPPED_AVFRAME, .write_header = opengl_write_header, .write_packet = opengl_write_packet, .write_uncoded_frame = opengl_write_frame, 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