X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fpngenc.c;h=bc61f8fd773245f434ad47fe119c071c6474032a;hb=0cdc77f1040c2c7eb9331b43a7f371ab60396b2a;hp=4204df2a3016223915d8011c78db3b2237aefb59;hpb=a440886a35e3329830d0c96311a80bd0f08ef6f3;p=ffmpeg diff --git a/libavcodec/pngenc.c b/libavcodec/pngenc.c index 4204df2a301..bc61f8fd773 100644 --- a/libavcodec/pngenc.c +++ b/libavcodec/pngenc.c @@ -31,6 +31,7 @@ #include "libavutil/libm.h" #include "libavutil/opt.h" #include "libavutil/color_utils.h" +#include "libavutil/stereo3d.h" #include @@ -340,6 +341,7 @@ static int png_get_gama(enum AVColorTransferCharacteristic trc, uint8_t *buf) static int encode_headers(AVCodecContext *avctx, const AVFrame *pict) { + AVFrameSideData *side_data; PNGEncContext *s = avctx->priv_data; /* write png header */ @@ -364,6 +366,23 @@ static int encode_headers(AVCodecContext *avctx, const AVFrame *pict) } png_write_chunk(&s->bytestream, MKTAG('p', 'H', 'Y', 's'), s->buf, 9); + /* write stereoscopic information */ + side_data = av_frame_get_side_data(pict, AV_FRAME_DATA_STEREO3D); + if (side_data) { + AVStereo3D *stereo3d = (AVStereo3D *)side_data->data; + switch (stereo3d->type) { + case AV_STEREO3D_SIDEBYSIDE: + s->buf[0] = ((stereo3d->flags & AV_STEREO3D_FLAG_INVERT) == 0) ? 1 : 0; + png_write_chunk(&s->bytestream, MKTAG('s', 'T', 'E', 'R'), s->buf, 1); + break; + case AV_STEREO3D_2D: + break; + default: + av_log(avctx, AV_LOG_WARNING, "Only side-by-side stereo3d flag can be defined within sTER chunk\n"); + break; + } + } + /* write colorspace information */ if (pict->color_primaries == AVCOL_PRI_BT709 && pict->color_trc == AVCOL_TRC_IEC61966_2_1) {