summaryrefslogtreecommitdiff
path: root/libavcodec/huffyuv.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-02-21 02:49:41 +0100
committerMichael Niedermayer <michaelni@gmx.at>2012-02-21 05:10:12 +0100
commiteadd4264ee4319abf9ec2f618ff925d7529f20ed (patch)
tree4251d4eb25af927cb290e24d1b6957d584638403 /libavcodec/huffyuv.c
parenta923b6b8f4f90d09c7c39cc8bfab7ee9d30a2843 (diff)
parent770a5c6d025e9c8eb3f5aba9cf1d7d7938fb918a (diff)
downloadffmpeg-eadd4264ee4319abf9ec2f618ff925d7529f20ed.tar.gz
Merge remote-tracking branch 'qatar/master'
* qatar/master: (36 commits) adpcmenc: Use correct frame_size for Yamaha ADPCM. avcodec: add ff_samples_to_time_base() convenience function to internal.h adx parser: set duration mlp parser: set duration instead of frame_size gsm parser: set duration mpegaudio parser: set duration instead of frame_size (e)ac3 parser: set duration instead of frame_size flac parser: set duration instead of frame_size avcodec: add duration field to AVCodecParserContext avutil: add av_rescale_q_rnd() to allow different rounding pnmdec: remove useless .pix_fmts libmp3lame: support float and s32 sample formats libmp3lame: renaming, rearrangement, alignment, and comments libmp3lame: use the LAME default bit rate libmp3lame: use avpriv_mpegaudio_decode_header() for output frame parsing libmp3lame: cosmetics: remove some pointless comments libmp3lame: convert some debugging code to av_dlog() libmp3lame: remove outdated comment. libmp3lame: do not set coded_frame->key_frame. libmp3lame: improve error handling in MP3lame_encode_init() ... Conflicts: doc/APIchanges libavcodec/libmp3lame.c libavcodec/pcxenc.c libavcodec/pnmdec.c libavcodec/pnmenc.c libavcodec/sgienc.c libavcodec/utils.c libavformat/hls.c libavutil/avutil.h libswscale/x86/swscale_mmx.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/huffyuv.c')
-rw-r--r--libavcodec/huffyuv.c29
1 files changed, 20 insertions, 9 deletions
diff --git a/libavcodec/huffyuv.c b/libavcodec/huffyuv.c
index 625d8fb186..ca94fc9042 100644
--- a/libavcodec/huffyuv.c
+++ b/libavcodec/huffyuv.c
@@ -1261,9 +1261,10 @@ static av_cold int decode_end(AVCodecContext *avctx)
#endif /* CONFIG_HUFFYUV_DECODER || CONFIG_FFVHUFF_DECODER */
#if CONFIG_HUFFYUV_ENCODER || CONFIG_FFVHUFF_ENCODER
-static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data){
+static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
+ const AVFrame *pict, int *got_packet)
+{
HYuvContext *s = avctx->priv_data;
- AVFrame *pict = data;
const int width= s->width;
const int width2= s->width>>1;
const int height= s->height;
@@ -1271,7 +1272,13 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size,
const int fake_ustride= s->interlaced ? pict->linesize[1]*2 : pict->linesize[1];
const int fake_vstride= s->interlaced ? pict->linesize[2]*2 : pict->linesize[2];
AVFrame * const p= &s->picture;
- int i, j, size=0;
+ int i, j, size = 0, ret;
+
+ if (!pkt->data &&
+ (ret = av_new_packet(pkt, width * height * 3 * 4 + FF_MIN_BUFFER_SIZE)) < 0) {
+ av_log(avctx, AV_LOG_ERROR, "Error allocating output packet.\n");
+ return ret;
+ }
*p = *pict;
p->pict_type= AV_PICTURE_TYPE_I;
@@ -1282,7 +1289,7 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size,
generate_len_table(s->len[i], s->stats[i]);
if(generate_bits_table(s->bits[i], s->len[i])<0)
return -1;
- size+= store_table(s, s->len[i], &buf[size]);
+ size += store_table(s, s->len[i], &pkt->data[size]);
}
for(i=0; i<3; i++)
@@ -1290,7 +1297,7 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size,
s->stats[i][j] >>= 1;
}
- init_put_bits(&s->pb, buf+size, buf_size-size);
+ init_put_bits(&s->pb, pkt->data + size, pkt->size - size);
if(avctx->pix_fmt == PIX_FMT_YUV422P || avctx->pix_fmt == PIX_FMT_YUV420P){
int lefty, leftu, leftv, y, cy;
@@ -1473,12 +1480,16 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size,
avctx->stats_out[0] = '\0';
if(!(s->avctx->flags2 & CODEC_FLAG2_NO_OUTPUT)){
flush_put_bits(&s->pb);
- s->dsp.bswap_buf((uint32_t*)buf, (uint32_t*)buf, size);
+ s->dsp.bswap_buf((uint32_t*)pkt->data, (uint32_t*)pkt->data, size);
}
s->picture_number++;
- return size*4;
+ pkt->size = size*4;
+ pkt->flags |= AV_PKT_FLAG_KEY;
+ *got_packet = 1;
+
+ return 0;
}
static av_cold int encode_end(AVCodecContext *avctx)
@@ -1531,7 +1542,7 @@ AVCodec ff_huffyuv_encoder = {
.id = CODEC_ID_HUFFYUV,
.priv_data_size = sizeof(HYuvContext),
.init = encode_init,
- .encode = encode_frame,
+ .encode2 = encode_frame,
.close = encode_end,
.pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV422P, PIX_FMT_RGB24, PIX_FMT_RGB32, PIX_FMT_NONE},
.long_name = NULL_IF_CONFIG_SMALL("Huffyuv / HuffYUV"),
@@ -1545,7 +1556,7 @@ AVCodec ff_ffvhuff_encoder = {
.id = CODEC_ID_FFVHUFF,
.priv_data_size = sizeof(HYuvContext),
.init = encode_init,
- .encode = encode_frame,
+ .encode2 = encode_frame,
.close = encode_end,
.pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_YUV422P, PIX_FMT_RGB24, PIX_FMT_RGB32, PIX_FMT_NONE},
.long_name = NULL_IF_CONFIG_SMALL("Huffyuv FFmpeg variant"),