summaryrefslogtreecommitdiff
path: root/libavcodec/pamenc.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-02-19 04:12:19 +0100
committerMichael Niedermayer <michaelni@gmx.at>2012-02-19 04:12:19 +0100
commit5d468edb2e947b804155b1d2e21b14b2a9d94320 (patch)
tree03b01a8f73708ddff1a3616801b8dd3aca8f4b6c /libavcodec/pamenc.c
parente98a76d3c293f8d125c24df8b06c42f23972e93b (diff)
pamenc: move allocation down.
This way the size that is calculated is known and can be used in a following commit. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/pamenc.c')
-rw-r--r--libavcodec/pamenc.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/libavcodec/pamenc.c b/libavcodec/pamenc.c
index ea0b6f4a32..b2c6c3ea9a 100644
--- a/libavcodec/pamenc.c
+++ b/libavcodec/pamenc.c
@@ -33,21 +33,6 @@ static int pam_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const char *tuple_type;
uint8_t *ptr;
- if ((ret = ff_alloc_packet(pkt, avpicture_get_size(avctx->pix_fmt,
- avctx->width,
- avctx->height) + 200)) < 0) {
- av_log(avctx, AV_LOG_ERROR, "encoded frame too large\n");
- return ret;
- }
-
- *p = *pict;
- p->pict_type = AV_PICTURE_TYPE_I;
- p->key_frame = 1;
-
- s->bytestream_start =
- s->bytestream = pkt->data;
- s->bytestream_end = pkt->data + pkt->size;
-
h = avctx->height;
w = avctx->width;
switch (avctx->pix_fmt) {
@@ -102,6 +87,22 @@ static int pam_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
default:
return -1;
}
+
+ if ((ret = ff_alloc_packet(pkt, avpicture_get_size(avctx->pix_fmt,
+ avctx->width,
+ avctx->height) + 200)) < 0) {
+ av_log(avctx, AV_LOG_ERROR, "encoded frame too large\n");
+ return ret;
+ }
+
+ *p = *pict;
+ p->pict_type = AV_PICTURE_TYPE_I;
+ p->key_frame = 1;
+
+ s->bytestream_start =
+ s->bytestream = pkt->data;
+ s->bytestream_end = pkt->data + pkt->size;
+
snprintf(s->bytestream, s->bytestream_end - s->bytestream,
"P7\nWIDTH %d\nHEIGHT %d\nDEPTH %d\nMAXVAL %d\nTUPLTYPE %s\nENDHDR\n",
w, h, depth, maxval, tuple_type);