Il giorno 10/ago/2013, alle ore 13:26, Anton Khirnov
<[email protected]> ha scritto:

>
> Sorry I'm late to the party, was too busy before.
>
> On Fri,  2 Aug 2013 19:07:38 +0200, Vittorio Giovara 
> <[email protected]> wrote:
>> ---
>> Changelog               |    1 +
>> libavcodec/avcodec.h    |   23 +++++++++
>> libavutil/Makefile      |    1 +
>> libavutil/frame.h       |    4 ++
>> libavutil/stereoscopy.h |  130 
>> +++++++++++++++++++++++++++++++++++++++++++++++
>> 5 files changed, 159 insertions(+)
>> create mode 100644 libavutil/stereoscopy.h
>>
>> diff --git a/Changelog b/Changelog
>> index 37e5a60..a2cd0c3 100644
>> --- a/Changelog
>> +++ b/Changelog
>> @@ -26,6 +26,7 @@ version 10:
>> - Go2Webinar decoder
>> - WavPack encoding through libwavpack
>> - Added the -n parameter to avconv
>> +- stereo3d metadata
>>
>>
>> version 9:
>> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
>> index bd9a80c..d54b081 100644
>> --- a/libavcodec/avcodec.h
>> +++ b/libavcodec/avcodec.h
>> @@ -803,6 +803,29 @@ typedef struct AVPanScan{
>>     int16_t position[3][2];
>> }AVPanScan;
>>
>> +/**
>> + * Stereo 3D area.
>> + * This specifies the area which should be displayed.
>> + * Normally there is only one (or less) of such area per frame.
>> + */
>> +typedef struct AVStereo3D {
>> +    /**
>> +     * type
>> +     * - encoding: Set by libavcodec.
>> +     * - decoding: Set by libavcodec.
>> +     */
>> +    int type;
>> +
>> +    /**
>> +     * additional data
>> +     * - encoding: Set by libavcodec.
>> +     * - decoding: Set by libavcodec.
>> +     */
>> +    int extra;
>> +
>> +    /* free space? what additional metadata could be added? */
>> +} AVStereo3D;
>
> Maybe this was already discussed, but why is this in lavc? It seems quite 
> weird,
> when everything else in is lavu. I imagine lavfi filters might potentially 
> want
> to extract and use this stuff.

I only put this in lavc because I modeled AVStereo3D after AVPanScan,
the only other side data of AVFrame. Yes filters are good use cases
for this so I'll move it to lavu.

> Also if you're not sure how/if you'll want to extend this struct in the 
> future,
> then you need a constructor function, so we don't have to break ABI each time 
> we
> add a member to it.

Actually I'm not sure if the added complexity is worth it, the only
possible "expansion" of this struct is for auto stereoscopic videos
(depth maps and similar) but the current status is so fuzzy that maybe
they could use another struct entirely in the future.

>
>> +
>> #define FF_QSCALE_TYPE_MPEG1 0
>> #define FF_QSCALE_TYPE_MPEG2 1
>> #define FF_QSCALE_TYPE_H264  2
>> diff --git a/libavutil/Makefile b/libavutil/Makefile
>> index 910f6f0..db33ff7 100644
>> --- a/libavutil/Makefile
>> +++ b/libavutil/Makefile
>> @@ -41,6 +41,7 @@ HEADERS = adler32.h                                        
>>              \
>>           rational.h                                                    \
>>           samplefmt.h                                                   \
>>           sha.h                                                         \
>> +          stereoscopy.h                                                 \
>>           time.h                                                        \
>>           version.h                                                     \
>>           xtea.h                                                        \
>> diff --git a/libavutil/frame.h b/libavutil/frame.h
>> index d71948d..4270f6b 100644
>> --- a/libavutil/frame.h
>> +++ b/libavutil/frame.h
>> @@ -35,6 +35,10 @@ enum AVFrameSideDataType {
>>      * The data is the AVPanScan struct defined in libavcodec.
>>      */
>>     AV_FRAME_DATA_PANSCAN,
>> +    /**
>> +     * The data is the AVStereo3D struct defined in libavcodec.
>> +     */
>> +    AV_FRAME_DATA_STEREO3D,
>> };
>>
>> typedef struct AVFrameSideData {
>> diff --git a/libavutil/stereoscopy.h b/libavutil/stereoscopy.h
>> new file mode 100644
>> index 0000000..e354515
>> --- /dev/null
>> +++ b/libavutil/stereoscopy.h
>> @@ -0,0 +1,130 @@
>> +/*
>> + * Copyright (c) 2013 Vittorio Giovara <[email protected]>
>> + *
>> + * This file is part of Libav.
>> + *
>> + * Libav 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.
>> + *
>> + * Libav 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 Libav; if not, write to the Free Software
>> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
>> USA
>> + */
>> +
>> +
>> +/* How views are packed within the frame or container*/
>> +enum AVStereo3DType {
>> +    /* Video is not stereoscopic */
>> +    AV_STEREO3D_NONE,
>> +
>> +    /* Video is not stereoscopic but metadata has to be there */
>
> What does this mean?

It's a funny story: there may be 3d videos that contain portions of 2d
videos and the switch was originally left to the container. However at
least for h264 the periodicity of the fpa SEI message and the mpeg2 ts
flag "frame_packing_not_present_flag" (iirc) is different and you
could have a 2d->3d (or 3d->2d) switch to early or too late. So they
introduce a new fpa type value that explicitly marks the video as 2d.

>
> Also the docs are not in doxygen format, you need one more *.

I'll amend this.

>
>> +    AV_STEREO3D_NOT_REALLY,
>> +
>> +    /* Views are colored funny */
>> +    AV_STEREO3D_ANAGLYPH,
>> +
>> +    /* Views are in two different streams
>> +     *  could be per container (like Matroska)
>> +     *  or per frame (like MVC Stereo profile)
>> +     */
>> +    AV_STEREO3D_MULTISTREAM,
>> +
>> +    /* Views are alternated temporally
>> +     *
>> +     *     frame0   frame1   frame2   ...
>> +     *    LLLLLLLL RRRRRRRR LLLLLLLL
>> +     *    LLLLLLLL RRRRRRRR LLLLLLLL
>> +     *    LLLLLLLL RRRRRRRR LLLLLLLL
>> +     *    ...      ...      ...
>> +     */
>> +    AV_STEREO3D_FRAMESEQUENCE,
>> +
>> +    /* Views are packed in a checkerboard-like structure per pixel
>> +     *
>> +     *    LRLRLRLR
>> +     *    RLRLRLRL
>> +     *    LRLRLRLR
>> +     *    ...
>> +     */
>> +    AV_STEREO3D_CHECKERS,
>> +
>> +    /* Views are packed per line, as if interlaced
>> +     *
>> +     *    LLLLLLLL
>> +     *    RRRRRRRR
>> +     *    LLLLLLLL
>> +     *    ...
>> +     */
>> +    AV_STEREO3D_LINES,
>> +
>> +    /* Views are packed per column
>> +     *
>> +     *    LRLRLRLR
>> +     *    LRLRLRLR
>> +     *    LRLRLRLR
>> +     *    ...
>> +     */
>> +    AV_STEREO3D_COLUMNS,
>> +
>> +    /* Views are next to each other
>> +     *
>> +     *    LLLLRRRR
>> +     *    LLLLRRRR
>> +     *    LLLLRRRR
>> +     *    ...
>> +     */
>> +    AV_STEREO3D_SIDEBYSIDE,
>> +
>> +    /* Views are on top of each other
>> +     *
>> +     *    LLLLLLLL
>> +     *    LLLLLLLL
>> +     *    RRRRRRRR
>> +     *    RRRRRRRR
>> +     */
>> +    AV_STEREO3D_TOPBOTTOM,
>> +};
>> +
>> +
>> +enum AVStereo3DInfo {
>> +    /* Views are assumed to be at full resolution and is
>> +     * "Left is Left" mode, with no other fancy stuff
>> +     */
>> +    AV_STEREO3D_NORMAL                   = 0x00000000,
>> +
>> +    /* View are at half resolution */
>> +    AV_STEREO3D_SIZE_HALF                = 0x00000001,
>> +
>> +    /* Invert views, L becomes R and R becomes L */
>> +    AV_STEREO3D_ORDER_INVERT             = 0x00000002,
>> +
>> +    /* When upscaling apply a checkerboard pattern, like
>> +     *
>> +     *     LLLLRRRR          L L L L    R R R R
>> +     *     LLLLRRRR    =>     L L L L  R R R R
>> +     *     LLLLRRRR          L L L L    R R R R
>> +     *     LLLLRRRR           L L L L  R R R R
>> +     */
>> +    AV_STEREO3D_QUINCUNX                 = 0x00000004,
>> +
>> +    /* Video surface also contains a depth map */
>> +    AV_STEREO3D_DEPTH                    = 0x00000008,
>> +};
>> +
>> +// Unused for now
>> +enum AVStereo3DAnalgyph {
>> +    AV_STEREO3D_ANAGLYPH_RED_CYAN,
>> +    AV_STEREO3D_ANAGLYPH_GREEN_MAGENTA,
>> +    AV_STEREO3D_ANAGLYPH_AMBER_BLUE,
>> +    AV_STEREO3D_ANAGLYPH_RED_GREEN,
>> +    AV_STEREO3D_ANAGLYPH_RED_BLUE,
>> +    AV_STEREO3D_ANAGLYPH_MAGENTA_CYAN,
>> +};
>
> Those two are unused, do you have any plans to use them?
> I'm not a fan of unused stuff lying around, it tends to rot and we might 
> realize
> later we should have done some stuff differently.

AVStereo3DInfo is used in a few places, like mpeg2's quincunx or
h264's content interpretation type. Anaglyph types instead are more
related to the rending side so I'll drop them.

There is one more thing I would like to add to this patchset, that is
being able to add this metadata externally, like from avconv. How
could this be done cleanly?

>
> --
> Anton Khirnov

Vittorio
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to