[FFmpeg-devel] [PATCH v8 1/3] avcodec: add side data type for ancillary

Patrick Keroulas patrick.keroulas at savoirfairelinux.com
Wed Jul 11 00:51:59 EEST 2018


Ancillary data can carry various side data that can't be transmitted in
bitstreams. For now, this struct includes interlaced field flags and
the must be attached to an AVPacket as side data.

Signed-off-by: Patrick Keroulas <patrick.keroulas at savoirfairelinux.com>
---

Changes v7 -> v8:
 * Merge the definition of AVAncillaryData and its allocation in
avcodec.h in a single patch.

---
---
 doc/APIchanges             |  3 +++
 libavcodec/avcodec.h       |  7 +++++-
 libavcodec/avpacket.c      |  1 +
 libavcodec/version.h       |  4 ++--
 libavutil/Makefile         |  2 ++
 libavutil/ancillary_data.c | 27 ++++++++++++++++++++++
 libavutil/ancillary_data.h | 56 ++++++++++++++++++++++++++++++++++++++++++++++
 libavutil/version.h        |  4 ++--
 8 files changed, 99 insertions(+), 5 deletions(-)
 create mode 100644 libavutil/ancillary_data.c
 create mode 100644 libavutil/ancillary_data.h

diff --git a/doc/APIchanges b/doc/APIchanges
index efe15ba..ff2baff 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,9 @@ libavutil:     2017-10-21
 
 API changes, most recent first:
 
+2018-05-xx - xxxxxxxxxx - lavc 58.20.100 - avcodec.h
+  Add AV_PKT_DATA_ANCILLARY to hold various side data.
+
 2018-05-xx - xxxxxxxxxx - lavf 58.15.100 - avformat.h
   Add pmt_version field to AVProgram
 
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index f85af3f..658bd9e 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1360,6 +1360,12 @@ enum AVPacketSideDataType {
     AV_PKT_DATA_ENCRYPTION_INFO,
 
     /**
+     * Generic side data for any parameter that can't fit in a AVPacket,
+     * e.g. interlaced field flags.
+     */
+    AV_PKT_DATA_ANCILLARY,
+
+    /**
      * The number of side data types.
      * This is not part of the public API/ABI in the sense that it may
      * change when new side data types are added.
@@ -1482,7 +1488,6 @@ typedef struct AVPacket {
  */
 #define AV_PKT_FLAG_DISPOSABLE 0x0010
 
-
 enum AVSideDataParamChangeFlags {
     AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT  = 0x0001,
     AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT = 0x0002,
diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c
index 99a0c13..27355e1 100644
--- a/libavcodec/avpacket.c
+++ b/libavcodec/avpacket.c
@@ -388,6 +388,7 @@ const char *av_packet_side_data_name(enum AVPacketSideDataType type)
     case AV_PKT_DATA_CONTENT_LIGHT_LEVEL:        return "Content light level metadata";
     case AV_PKT_DATA_SPHERICAL:                  return "Spherical Mapping";
     case AV_PKT_DATA_A53_CC:                     return "A53 Closed Captions";
+    case AV_PKT_DATA_ANCILLARY:                  return "Ancillary data";
     }
     return NULL;
 }
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 471ea4a..3f0d98e 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -28,8 +28,8 @@
 #include "libavutil/version.h"
 
 #define LIBAVCODEC_VERSION_MAJOR  58
-#define LIBAVCODEC_VERSION_MINOR  21
-#define LIBAVCODEC_VERSION_MICRO 104
+#define LIBAVCODEC_VERSION_MINOR  22
+#define LIBAVCODEC_VERSION_MICRO 100
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
                                                LIBAVCODEC_VERSION_MINOR, \
diff --git a/libavutil/Makefile b/libavutil/Makefile
index 9ed24cf..100ce10 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -4,6 +4,7 @@ DESC = FFmpeg utility library
 HEADERS = adler32.h                                                     \
           aes.h                                                         \
           aes_ctr.h                                                     \
+          ancillary_data.h                                              \
           attributes.h                                                  \
           audio_fifo.h                                                  \
           avassert.h                                                    \
@@ -92,6 +93,7 @@ BUILT_HEADERS = avconfig.h                                              \
 OBJS = adler32.o                                                        \
        aes.o                                                            \
        aes_ctr.o                                                        \
+       ancillary_data.o                                                 \
        audio_fifo.o                                                     \
        avstring.o                                                       \
        base64.o                                                         \
diff --git a/libavutil/ancillary_data.c b/libavutil/ancillary_data.c
new file mode 100644
index 0000000..26686b8
--- /dev/null
+++ b/libavutil/ancillary_data.c
@@ -0,0 +1,27 @@
+/**
+ * Copyright (c) 2018 Patrick Keroulas <patrick.keroulas at savoirfairelinux.com>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "ancillary_data.h"
+#include "mem.h"
+
+AVAncillaryData *av_ancillary_data_alloc(void)
+{
+    return av_mallocz(sizeof(AVAncillaryData));
+}
diff --git a/libavutil/ancillary_data.h b/libavutil/ancillary_data.h
new file mode 100644
index 0000000..d5a9da3
--- /dev/null
+++ b/libavutil/ancillary_data.h
@@ -0,0 +1,56 @@
+/**
+ * Copyright (c) 2018 Patrick Keroulas <patrick.keroulas at savoirfairelinux.com>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVUTIL_ANCILLARY_DATA_H
+#define AVUTIL_ANCILLARY_DATA_H
+
+#include <stdint.h>
+
+enum AVAncillaryDataFields {
+    AV_ANCILLARY_DATA_FIELD_NONE         = 0x00,
+    AV_ANCILLARY_DATA_FIELD_TOP_FIELD    = 0x01,
+    AV_ANCILLARY_DATA_FIELD_BOTTOM_FIELD = 0x02,
+};
+
+/**
+ * Ancillary data carries various side data that can't be transmitted in
+ * AV bit streams for codecs like bitpacked or v210.
+ *
+ * To be used as payload of a AVPacketSideData.
+ *
+ */
+typedef struct AVAncillaryData {
+    /**
+     * Flags to determine if the AVPacket holds a top/bottom field in
+     * case of interlaced format.
+     */
+    uint8_t field;
+} AVAncillaryData;
+
+/**
+ * Allocate an AVAncillaryData structure and set its fields to
+ * default values. The resulting struct can be freed using av_freep().
+ *
+ * @return An AVAncillaryData filled with default values or NULL
+ *         on failure.
+ */
+AVAncillaryData *av_ancillary_data_alloc(void);
+
+#endif /* AVUTIL_ANCILLARY_DATA_H */
diff --git a/libavutil/version.h b/libavutil/version.h
index 44bdebd..84409b1 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,8 +79,8 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR  56
-#define LIBAVUTIL_VERSION_MINOR  18
-#define LIBAVUTIL_VERSION_MICRO 102
+#define LIBAVUTIL_VERSION_MINOR  19
+#define LIBAVUTIL_VERSION_MICRO 100
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
                                                LIBAVUTIL_VERSION_MINOR, \
-- 
2.7.4



More information about the ffmpeg-devel mailing list