Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-02-21 05:49:41 +0400
committerMichael Niedermayer <michaelni@gmx.at>2012-02-21 08:10:12 +0400
commiteadd4264ee4319abf9ec2f618ff925d7529f20ed (patch)
tree4251d4eb25af927cb290e24d1b6957d584638403 /libavcodec/pcxenc.c
parenta923b6b8f4f90d09c7c39cc8bfab7ee9d30a2843 (diff)
parent770a5c6d025e9c8eb3f5aba9cf1d7d7938fb918a (diff)
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/pcxenc.c')
-rw-r--r--libavcodec/pcxenc.c31
1 files changed, 22 insertions, 9 deletions
diff --git a/libavcodec/pcxenc.c b/libavcodec/pcxenc.c
index a39e221805..65b3935476 100644
--- a/libavcodec/pcxenc.c
+++ b/libavcodec/pcxenc.c
@@ -29,6 +29,7 @@
#include "avcodec.h"
#include "bytestream.h"
#include "libavutil/imgutils.h"
+#include "internal.h"
typedef struct PCXContext {
AVFrame picture;
@@ -96,20 +97,20 @@ static int pcx_rle_encode( uint8_t *dst, int dst_size,
return dst - dst_start;
}
-static int pcx_encode_frame(AVCodecContext *avctx,
- unsigned char *buf, int buf_size, void *data)
+static int pcx_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
+ const AVFrame *frame, int *got_packet)
{
PCXContext *s = avctx->priv_data;
AVFrame *const pict = &s->picture;
- const uint8_t *buf_start = buf;
- const uint8_t *buf_end = buf + buf_size;
+ const uint8_t *buf_end;
+ uint8_t *buf;
- int bpp, nplanes, i, y, line_bytes, written;
+ int bpp, nplanes, i, y, line_bytes, written, ret, max_pkt_size;
const uint32_t *pal = NULL;
uint32_t palette256[256];
const uint8_t *src;
- *pict = *(AVFrame *)data;
+ *pict = *frame;
pict->pict_type = AV_PICTURE_TYPE_I;
pict->key_frame = 1;
@@ -151,6 +152,14 @@ static int pcx_encode_frame(AVCodecContext *avctx,
line_bytes = (avctx->width * bpp + 7) >> 3;
line_bytes = (line_bytes + 1) & ~1;
+ max_pkt_size = 128 + avctx->height * 2 * line_bytes * nplanes + (pal ? 256*3 + 1 : 0);
+ if ((ret = ff_alloc_packet(pkt, max_pkt_size)) < 0) {
+ av_log(avctx, AV_LOG_ERROR, "Error getting output packet of size %d.\n", max_pkt_size);
+ return ret;
+ }
+ buf = pkt->data;
+ buf_end = pkt->data + pkt->size;
+
bytestream_put_byte(&buf, 10); // manufacturer
bytestream_put_byte(&buf, 5); // version
bytestream_put_byte(&buf, 1); // encoding
@@ -167,7 +176,7 @@ static int pcx_encode_frame(AVCodecContext *avctx,
bytestream_put_byte(&buf, nplanes); // number of planes
bytestream_put_le16(&buf, line_bytes); // scanline plane size in bytes
- while (buf - buf_start < 128)
+ while (buf - pkt->data < 128)
*buf++= 0;
src = pict->data[0];
@@ -193,7 +202,11 @@ static int pcx_encode_frame(AVCodecContext *avctx,
}
}
- return buf - buf_start;
+ pkt->size = buf - pkt->data;
+ pkt->flags |= AV_PKT_FLAG_KEY;
+ *got_packet = 1;
+
+ return 0;
}
AVCodec ff_pcx_encoder = {
@@ -202,7 +215,7 @@ AVCodec ff_pcx_encoder = {
.id = CODEC_ID_PCX,
.priv_data_size = sizeof(PCXContext),
.init = pcx_encode_init,
- .encode = pcx_encode_frame,
+ .encode2 = pcx_encode_frame,
.pix_fmts = (const enum PixelFormat[]){
PIX_FMT_RGB24,
PIX_FMT_RGB8, PIX_FMT_BGR8, PIX_FMT_RGB4_BYTE, PIX_FMT_BGR4_BYTE, PIX_FMT_GRAY8, PIX_FMT_PAL8,