diff mbox

[FFmpeg-devel,v3,06/25] avcodec/avcodec, avformat/movenc: introduced AV_PKT_DATA_TRACK_ALTERNATE_GROUP side data for expressing alternate groups

Message ID 1474291548-17810-7-git-send-email-erkki.seppala.ext@nokia.com
State Changes Requested
Headers show

Commit Message

erkki.seppala.ext@nokia.com Sept. 19, 2016, 1:25 p.m. UTC
Alternate groups previously always generated for ISO media files. With
this addition client code can define track groups arbitrarily.

Signed-off-by: Erkki Seppälä <erkki.seppala.ext@nokia.com>
Signed-off-by: OZOPlayer <OZOPL@nokia.com>
---
 libavcodec/avcodec.h | 11 +++++++++++
 libavformat/movenc.c |  9 +++++++++
 2 files changed, 20 insertions(+)

Comments

Michael Niedermayer Dec. 17, 2016, 6:31 p.m. UTC | #1
On Mon, Sep 19, 2016 at 04:25:29PM +0300, Erkki Seppälä wrote:
> Alternate groups previously always generated for ISO media files. With
> this addition client code can define track groups arbitrarily.
> 
> Signed-off-by: Erkki Seppälä <erkki.seppala.ext@nokia.com>
> Signed-off-by: OZOPlayer <OZOPL@nokia.com>
> ---
>  libavcodec/avcodec.h | 11 +++++++++++
>  libavformat/movenc.c |  9 +++++++++
>  2 files changed, 20 insertions(+)

patches/commits should only touch oen lib at a time


> 
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index 56bb9b0..3be54d4 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -1543,6 +1543,17 @@ enum AVPacketSideDataType {
>       * indicated by the key's length.
>       */
>      AV_PKT_DATA_TRACK_REFERENCES,
> +
> +    /**
> +     * Assign alternate groups for tracks. An example of alternate
> +     * groups would be audio tracks (or video tracks) that are
> +     * alternative to each other. Each alternative track shares the
> +     * same non-zero alternate group.
> +     *
> +     * The content is:
> +     * uint: The alternate group of this track
> +     */
> +    AV_PKT_DATA_TRACK_ALTERNATE_GROUP,
>  };

this requires version bump and APIChanges update


[...]
diff mbox

Patch

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 56bb9b0..3be54d4 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1543,6 +1543,17 @@  enum AVPacketSideDataType {
      * indicated by the key's length.
      */
     AV_PKT_DATA_TRACK_REFERENCES,
+
+    /**
+     * Assign alternate groups for tracks. An example of alternate
+     * groups would be audio tracks (or video tracks) that are
+     * alternative to each other. Each alternative track shares the
+     * same non-zero alternate group.
+     *
+     * The content is:
+     * uint: The alternate group of this track
+     */
+    AV_PKT_DATA_TRACK_ALTERNATE_GROUP,
 };
 
 #define AV_PKT_DATA_QUALITY_FACTOR AV_PKT_DATA_QUALITY_STATS //DEPRECATED
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index aed30dc..b2e87ed 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -2407,6 +2407,8 @@  static int mov_write_tkhd_tag(AVIOContext *pb, MOVMuxContext *mov,
     int flags   = MOV_TKHD_FLAG_IN_MOVIE;
     int rotation = 0;
     int group   = 0;
+    int *alternate_group = NULL;
+    int alternate_group_size;
 
     uint32_t *display_matrix = NULL;
     int      display_matrix_size, i;
@@ -2423,6 +2425,13 @@  static int mov_write_tkhd_tag(AVIOContext *pb, MOVMuxContext *mov,
             display_matrix = NULL;
     }
 
+    if (st) {
+        alternate_group = (int*) av_stream_get_side_data(st, AV_PKT_DATA_TRACK_ALTERNATE_GROUP,
+                                                         &alternate_group_size);
+        if (alternate_group && alternate_group_size >= sizeof(int))
+            group = *alternate_group;
+    }
+
     if (track->flags & MOV_TRACK_ENABLED)
         flags |= MOV_TKHD_FLAG_ENABLED;