aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/dpxenc.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-02-18 02:20:19 +0100
committerMichael Niedermayer <michaelni@gmx.at>2012-02-18 02:20:19 +0100
commitbbb61a1cd5cb2046e480f367a7ae58a32f2ef907 (patch)
tree0e7cc2b59558e2dc31d6b8752d90f6b5b5c886e5 /libavcodec/dpxenc.c
parentf6492476a63938cc66c51bf61c88407b7749f780 (diff)
parentaf468015d972c0dec5c8c37b2685ffa5cbe4ae87 (diff)
downloadffmpeg-bbb61a1cd5cb2046e480f367a7ae58a32f2ef907.tar.gz
Merge remote-tracking branch 'qatar/master'
* qatar/master: (22 commits) als: prevent infinite loop in zero_remaining(). cook: prevent div-by-zero if channels is zero. pamenc: switch to encode2(). svq1enc: switch to encode2(). dvenc: switch to encode2(). dpxenc: switch to encode2(). pngenc: switch to encode2(). v210enc: switch to encode2(). xwdenc: switch to encode2(). ttadec: use branchless unsigned-to-signed unfolding avcodec: add a Sun Rasterfile encoder sunrast: Move common defines to a new header file. cdxl: fix video decoding for some files cdxl: fix audio for some samples apetag: add proper support for binary tags ttadec: remove dead code swscale: make access to filter data conditional on filter type. swscale: update context offsets after removal of AlpMmxFilter. prores: initialise encoder and decoder parts only when needed swscale: make monowhite/black RGB-independent. ... Conflicts: Changelog libavcodec/alsdec.c libavcodec/dpxenc.c libavcodec/golomb.h libavcodec/pamenc.c libavcodec/pngenc.c libavformat/img2.c libswscale/output.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/dpxenc.c')
-rw-r--r--libavcodec/dpxenc.c35
1 files changed, 23 insertions, 12 deletions
diff --git a/libavcodec/dpxenc.c b/libavcodec/dpxenc.c
index de32e4e959..bde02bce1c 100644
--- a/libavcodec/dpxenc.c
+++ b/libavcodec/dpxenc.c
@@ -22,6 +22,7 @@
#include "libavutil/intreadwrite.h"
#include "libavutil/imgutils.h"
#include "avcodec.h"
+#include "internal.h"
typedef struct DPXContext {
AVFrame picture;
@@ -104,14 +105,23 @@ static void encode_rgb48_10bit(AVCodecContext *avctx, const AVPicture *pic, uint
}
}
-static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data)
+static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
+ const AVFrame *frame, int *got_packet)
{
DPXContext *s = avctx->priv_data;
- int size;
+ int size, ret;
+ uint8_t *buf;
#define HEADER_SIZE 1664 /* DPX Generic header */
- if (buf_size < HEADER_SIZE)
- return -1;
+ if (s->bits_per_component == 10)
+ size = avctx->height * avctx->width * 4;
+ else
+ size = avpicture_get_size(avctx->pix_fmt, avctx->width, avctx->height);
+ if ((ret = ff_alloc_packet(pkt, size + HEADER_SIZE)) < 0) {
+ av_log(avctx, AV_LOG_ERROR, "Error getting output packet.\n");
+ return ret;
+ }
+ buf = pkt->data;
memset(buf, 0, HEADER_SIZE);
@@ -144,17 +154,14 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size,
switch(s->bits_per_component) {
case 8:
case 16:
- size = avpicture_layout(data, avctx->pix_fmt,
+ size = avpicture_layout((const AVPicture*)frame, avctx->pix_fmt,
avctx->width, avctx->height,
- buf + HEADER_SIZE, buf_size - HEADER_SIZE);
+ buf + HEADER_SIZE, pkt->size - HEADER_SIZE);
if (size < 0)
return size;
break;
case 10:
- size = avctx->height * avctx->width * 4;
- if (buf_size < HEADER_SIZE + size)
- return -1;
- encode_rgb48_10bit(avctx, data, buf + HEADER_SIZE);
+ encode_rgb48_10bit(avctx, (const AVPicture*)frame, buf + HEADER_SIZE);
break;
default:
av_log(avctx, AV_LOG_ERROR, "Unsupported bit depth: %d\n", s->bits_per_component);
@@ -164,7 +171,11 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size,
size += HEADER_SIZE;
write32(buf + 16, size); /* file size */
- return size;
+
+ pkt->flags |= AV_PKT_FLAG_KEY;
+ *got_packet = 1;
+
+ return 0;
}
AVCodec ff_dpx_encoder = {
@@ -173,7 +184,7 @@ AVCodec ff_dpx_encoder = {
.id = CODEC_ID_DPX,
.priv_data_size = sizeof(DPXContext),
.init = encode_init,
- .encode = encode_frame,
+ .encode2 = encode_frame,
.pix_fmts = (const enum PixelFormat[]){
PIX_FMT_RGB24,
PIX_FMT_RGBA,