[FFmpeg-cvslog] avformat: Do not use AVFMT_RAWPICTURE

Luca Barbato git at videolan.org
Wed Oct 14 14:52:55 CEST 2015


ffmpeg | branch: master | Luca Barbato <lu_zero at gentoo.org> | Mon Oct 12 16:06:07 2015 +0200| [34ed5c2e4d9b7fe5c9b3aae2da5599fabb95c02e] | committer: Luca Barbato

avformat: Do not use AVFMT_RAWPICTURE

There are no formats supporting it anymore and it is deprecated.
Update the documentation accordingly.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=34ed5c2e4d9b7fe5c9b3aae2da5599fabb95c02e
---

 avconv.c               |   72 +++++++++++++++++-------------------------------
 doc/examples/output.c  |   42 ++++++++--------------------
 libavformat/avformat.h |    6 ++--
 libavformat/version.h  |    3 ++
 4 files changed, 44 insertions(+), 79 deletions(-)

diff --git a/avconv.c b/avconv.c
index 15836db..23f6db6 100644
--- a/avconv.c
+++ b/avconv.c
@@ -452,7 +452,7 @@ static void do_video_out(AVFormatContext *s,
                          AVFrame *in_picture,
                          int *frame_size)
 {
-    int ret, format_video_sync;
+    int ret, format_video_sync, got_packet;
     AVPacket pkt;
     AVCodecContext *enc = ost->enc_ctx;
 
@@ -488,57 +488,37 @@ static void do_video_out(AVFormatContext *s,
     if (ost->frame_number >= ost->max_frames)
         return;
 
-    if (s->oformat->flags & AVFMT_RAWPICTURE &&
-        enc->codec->id == AV_CODEC_ID_RAWVIDEO) {
-        /* raw pictures are written as AVPicture structure to
-           avoid any copies. We support temporarily the older
-           method. */
-#if FF_API_CODED_FRAME
-FF_DISABLE_DEPRECATION_WARNINGS
-        enc->coded_frame->interlaced_frame = in_picture->interlaced_frame;
-        enc->coded_frame->top_field_first  = in_picture->top_field_first;
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
-        pkt.data   = (uint8_t *)in_picture;
-        pkt.size   =  sizeof(AVPicture);
-        pkt.pts    = av_rescale_q(in_picture->pts, enc->time_base, ost->st->time_base);
-        pkt.flags |= AV_PKT_FLAG_KEY;
+    if (enc->flags & (AV_CODEC_FLAG_INTERLACED_DCT | AV_CODEC_FLAG_INTERLACED_ME) &&
+        ost->top_field_first >= 0)
+        in_picture->top_field_first = !!ost->top_field_first;
 
-        write_frame(s, &pkt, ost);
-    } else {
-        int got_packet;
-
-        if (enc->flags & (AV_CODEC_FLAG_INTERLACED_DCT | AV_CODEC_FLAG_INTERLACED_ME) &&
-            ost->top_field_first >= 0)
-            in_picture->top_field_first = !!ost->top_field_first;
-
-        in_picture->quality = enc->global_quality;
-        in_picture->pict_type = 0;
-        if (ost->forced_kf_index < ost->forced_kf_count &&
-            in_picture->pts >= ost->forced_kf_pts[ost->forced_kf_index]) {
-            in_picture->pict_type = AV_PICTURE_TYPE_I;
-            ost->forced_kf_index++;
-        }
+    in_picture->quality = enc->global_quality;
+    in_picture->pict_type = 0;
+    if (ost->forced_kf_index < ost->forced_kf_count &&
+        in_picture->pts >= ost->forced_kf_pts[ost->forced_kf_index]) {
+        in_picture->pict_type = AV_PICTURE_TYPE_I;
+        ost->forced_kf_index++;
+    }
 
-        ost->frames_encoded++;
+    ost->frames_encoded++;
 
-        ret = avcodec_encode_video2(enc, &pkt, in_picture, &got_packet);
-        if (ret < 0) {
-            av_log(NULL, AV_LOG_FATAL, "Video encoding failed\n");
-            exit_program(1);
-        }
+    ret = avcodec_encode_video2(enc, &pkt, in_picture, &got_packet);
+    if (ret < 0) {
+        av_log(NULL, AV_LOG_FATAL, "Video encoding failed\n");
+        exit_program(1);
+    }
 
-        if (got_packet) {
-            av_packet_rescale_ts(&pkt, enc->time_base, ost->st->time_base);
-            write_frame(s, &pkt, ost);
-            *frame_size = pkt.size;
+    if (got_packet) {
+        av_packet_rescale_ts(&pkt, enc->time_base, ost->st->time_base);
+        write_frame(s, &pkt, ost);
+        *frame_size = pkt.size;
 
-            /* if two pass, output log */
-            if (ost->logfile && enc->stats_out) {
-                fprintf(ost->logfile, "%s", enc->stats_out);
-            }
+        /* if two pass, output log */
+        if (ost->logfile && enc->stats_out) {
+            fprintf(ost->logfile, "%s", enc->stats_out);
         }
     }
+
     ost->sync_opts++;
     /*
      * For video, number of frames in == number of packets out.
@@ -959,8 +939,6 @@ static void flush_encoders(void)
 
         if (enc->codec_type == AVMEDIA_TYPE_AUDIO && enc->frame_size <= 1)
             continue;
-        if (enc->codec_type == AVMEDIA_TYPE_VIDEO && (os->oformat->flags & AVFMT_RAWPICTURE) && enc->codec->id == AV_CODEC_ID_RAWVIDEO)
-            continue;
 
         for (;;) {
             int (*encode)(AVCodecContext*, AVPacket*, const AVFrame*, int*) = NULL;
diff --git a/doc/examples/output.c b/doc/examples/output.c
index af5445b..c883429 100644
--- a/doc/examples/output.c
+++ b/doc/examples/output.c
@@ -491,48 +491,30 @@ static int write_video_frame(AVFormatContext *oc, OutputStream *ost)
     int ret;
     AVCodecContext *c;
     AVFrame *frame;
+    AVPacket pkt   = { 0 };
     int got_packet = 0;
 
     c = ost->st->codec;
 
     frame = get_video_frame(ost);
 
-    if (oc->oformat->flags & AVFMT_RAWPICTURE) {
-        /* a hack to avoid data copy with some raw video muxers */
-        AVPacket pkt;
-        av_init_packet(&pkt);
-
-        if (!frame)
-            return 1;
+    av_init_packet(&pkt);
 
-        pkt.flags        |= AV_PKT_FLAG_KEY;
-        pkt.stream_index  = ost->st->index;
-        pkt.data          = (uint8_t *)frame;
-        pkt.size          = sizeof(AVPicture);
+    /* encode the image */
+    ret = avcodec_encode_video2(c, &pkt, frame, &got_packet);
+    if (ret < 0) {
+        fprintf(stderr, "Error encoding a video frame\n");
+        exit(1);
+    }
 
-        pkt.pts = pkt.dts = frame->pts;
+    if (got_packet) {
         av_packet_rescale_ts(&pkt, c->time_base, ost->st->time_base);
+        pkt.stream_index = ost->st->index;
 
+        /* Write the compressed frame to the media file. */
         ret = av_interleaved_write_frame(oc, &pkt);
-    } else {
-        AVPacket pkt = { 0 };
-        av_init_packet(&pkt);
-
-        /* encode the image */
-        ret = avcodec_encode_video2(c, &pkt, frame, &got_packet);
-        if (ret < 0) {
-            fprintf(stderr, "Error encoding a video frame\n");
-            exit(1);
-        }
-
-        if (got_packet) {
-            av_packet_rescale_ts(&pkt, c->time_base, ost->st->time_base);
-            pkt.stream_index = ost->st->index;
-
-            /* Write the compressed frame to the media file. */
-            ret = av_interleaved_write_frame(oc, &pkt);
-        }
     }
+
     if (ret != 0) {
         fprintf(stderr, "Error while writing video frame\n");
         exit(1);
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index aa11cff..143a986 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -413,8 +413,10 @@ typedef struct AVProbeData {
 #define AVFMT_NOFILE        0x0001
 #define AVFMT_NEEDNUMBER    0x0002 /**< Needs '%d' in filename. */
 #define AVFMT_SHOW_IDS      0x0008 /**< Show format stream IDs numbers. */
+#if FF_API_LAVF_FMT_RAWPICTURE
 #define AVFMT_RAWPICTURE    0x0020 /**< Format wants AVPicture structure for
-                                      raw picture data. */
+                                      raw picture data. @deprecated Not used anymore */
+#endif
 #define AVFMT_GLOBALHEADER  0x0040 /**< Format wants global header. */
 #define AVFMT_NOTIMESTAMPS  0x0080 /**< Format does not need / have any timestamps. */
 #define AVFMT_GENERIC_INDEX 0x0100 /**< Use generic index building code. */
@@ -454,7 +456,7 @@ typedef struct AVOutputFormat {
     enum AVCodecID video_codec;    /**< default video codec */
     enum AVCodecID subtitle_codec; /**< default subtitle codec */
     /**
-     * can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_RAWPICTURE,
+     * can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER,
      * AVFMT_GLOBALHEADER, AVFMT_NOTIMESTAMPS, AVFMT_VARIABLE_FPS,
      * AVFMT_NODIMENSIONS, AVFMT_NOSTREAMS, AVFMT_ALLOW_FLUSH,
      * AVFMT_TS_NONSTRICT
diff --git a/libavformat/version.h b/libavformat/version.h
index f8dbd6e..d74968a 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -57,5 +57,8 @@
 #ifndef FF_API_LAVF_CODEC_TB
 #define FF_API_LAVF_CODEC_TB            (LIBAVFORMAT_VERSION_MAJOR < 58)
 #endif
+#ifndef FF_API_LAVF_FMT_RAWPICTURE
+#define FF_API_LAVF_FMT_RAWPICTURE      (LIBAVFORMAT_VERSION_MAJOR < 58)
+#endif
 
 #endif /* AVFORMAT_VERSION_H */



More information about the ffmpeg-cvslog mailing list