diff options
author | Kirill Gavrilov <kirill@sview.ru> | 2015-10-27 18:27:03 +0100 |
---|---|---|
committer | Vittorio Giovara <vittorio.giovara@gmail.com> | 2015-10-30 12:46:56 +0100 |
commit | 1720791e36f9cc24c05efea5bb275ab52156ce50 (patch) | |
tree | 76b37115ae52e258ea3bc04c66e31727d6fd624c /libavcodec/pngenc.c | |
parent | 00b62968d079e63bf22028f253ac297292436ebe (diff) | |
download | ffmpeg-1720791e36f9cc24c05efea5bb275ab52156ce50.tar.gz |
png: read and write stereo3d frame side data information
Use optional sTER chunk defining side-by-side stereo pair
within "Extensions to the PNG 1.2 Specification", version 1.3.0.
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
Diffstat (limited to 'libavcodec/pngenc.c')
-rw-r--r-- | libavcodec/pngenc.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/libavcodec/pngenc.c b/libavcodec/pngenc.c index 6ab4b7f54c..28df5af066 100644 --- a/libavcodec/pngenc.c +++ b/libavcodec/pngenc.c @@ -19,6 +19,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/stereo3d.h" + #include "avcodec.h" #include "bytestream.h" #include "huffyuvencdsp.h" @@ -233,6 +235,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pict, int *got_packet) { PNGEncContext *s = avctx->priv_data; + AVFrameSideData *side_data; const AVFrame *const p = pict; int bit_depth, color_type, y, len, row_size, ret, is_progressive; int bits_per_pixel, pass_row_size, enc_row_size, max_packet_size; @@ -371,6 +374,25 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, } } + /* write stereoscopic information */ + side_data = av_frame_get_side_data(pict, AV_FRAME_DATA_STEREO3D); + if (side_data) { + AVStereo3D *stereo3d = (AVStereo3D *)side_data->data; + uint8_t sm; + switch (stereo3d->type) { + case AV_STEREO3D_SIDEBYSIDE: + sm = !(stereo3d->flags & AV_STEREO3D_FLAG_INVERT); + png_write_chunk(&s->bytestream, MKTAG('s', 'T', 'E', 'R'), &sm, 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; + } + } + /* now put each row */ s->zstream.avail_out = IOBUF_SIZE; s->zstream.next_out = s->buf; |