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

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-11-17 15:41:42 +0400
committerMichael Niedermayer <michaelni@gmx.at>2013-11-17 15:41:42 +0400
commitf4f7888bab7061f08c54356c285adaba24383dc0 (patch)
treecc1b39e0754ac80908cf929f71e5127b83174c48 /libavcodec/pcxenc.c
parenta0c0629dd963b00f989172f0c599353b6b288c37 (diff)
parentffe04c330335add4c6d70ab0bb98e6b3f4f7abfa (diff)
Merge commit 'ffe04c330335add4c6d70ab0bb98e6b3f4f7abfa'
* commit 'ffe04c330335add4c6d70ab0bb98e6b3f4f7abfa': libxvid: use the AVFrame API properly. pcxenc: use the AVFrame API properly. roqvideo: remove unused variables libschroedingerenc: use the AVFrame API properly. Conflicts: libavcodec/pcxenc.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/pcxenc.c')
-rw-r--r--libavcodec/pcxenc.c30
1 files changed, 23 insertions, 7 deletions
diff --git a/libavcodec/pcxenc.c b/libavcodec/pcxenc.c
index fa45888466..f48063b9b2 100644
--- a/libavcodec/pcxenc.c
+++ b/libavcodec/pcxenc.c
@@ -33,6 +33,24 @@
static const uint32_t monoblack_pal[16] = { 0x000000, 0xFFFFFF };
+static av_cold int pcx_encode_init(AVCodecContext *avctx)
+{
+ avctx->coded_frame = av_frame_alloc();
+ if (!avctx->coded_frame)
+ return AVERROR(ENOMEM);
+
+ avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
+ avctx->coded_frame->key_frame = 1;
+
+ return 0;
+}
+
+static av_cold int pcx_encode_close(AVCodecContext *avctx)
+{
+ av_frame_free(&avctx->coded_frame);
+ return 0;
+}
+
/**
* PCX run-length encoder
* @param dst output buffer
@@ -86,7 +104,6 @@ static int pcx_rle_encode( uint8_t *dst, int dst_size,
static int pcx_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *frame, int *got_packet)
{
- AVFrame *const pict = (AVFrame *) frame;
const uint8_t *buf_end;
uint8_t *buf;
@@ -95,9 +112,6 @@ static int pcx_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
uint32_t palette256[256];
const uint8_t *src;
- pict->pict_type = AV_PICTURE_TYPE_I;
- pict->key_frame = 1;
-
if (avctx->width > 65535 || avctx->height > 65535) {
av_log(avctx, AV_LOG_ERROR, "image dimensions do not fit in 16 bits\n");
return -1;
@@ -121,7 +135,7 @@ static int pcx_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
case AV_PIX_FMT_PAL8:
bpp = 8;
nplanes = 1;
- pal = (uint32_t *)pict->data[1];
+ pal = (uint32_t *)frame->data[1];
break;
case AV_PIX_FMT_MONOBLACK:
bpp = 1;
@@ -166,7 +180,7 @@ static int pcx_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
while (buf - pkt->data < 128)
*buf++= 0;
- src = pict->data[0];
+ src = frame->data[0];
for (y = 0; y < avctx->height; y++) {
if ((written = pcx_rle_encode(buf, buf_end - buf,
@@ -175,7 +189,7 @@ static int pcx_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
return -1;
}
buf += written;
- src += pict->linesize[0];
+ src += frame->linesize[0];
}
if (nplanes == 1 && bpp == 8) {
@@ -201,6 +215,8 @@ AVCodec ff_pcx_encoder = {
.long_name = NULL_IF_CONFIG_SMALL("PC Paintbrush PCX image"),
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_PCX,
+ .init = pcx_encode_init,
+ .close = pcx_encode_close,
.encode2 = pcx_encode_frame,
.pix_fmts = (const enum AVPixelFormat[]){
AV_PIX_FMT_RGB24,