]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/proresenc_anatoliy.c
Merge remote-tracking branch 'qatar/master'
[ffmpeg] / libavcodec / proresenc_anatoliy.c
index 1d85b1d309bbfbdab3fd65459a784c6056770f73..2a1b45753b54584c16769488a8a0bcb393ac962c 100644 (file)
  */
 
 /**
- * @file libavcodec/proresenc.c
+ * @file
+ * Apple ProRes encoder (Anatoliy Wasserman version)
  * Known FOURCCs: 'apch' (HQ), 'apcn' (SD), 'apcs' (LT), 'acpo' (Proxy)
  */
 
 #include "avcodec.h"
+#include "internal.h"
 #include "put_bits.h"
 #include "bytestream.h"
 #include "dsputil.h"
@@ -168,8 +170,7 @@ static void encode_codeword(PutBitContext *pb, int val, int codebook)
         exp = av_log2(val);
         zeros = exp - exp_order + switch_bits + 1;
         put_bits(pb, zeros, 0);
-        put_bits(pb, 1, 1);
-        put_bits(pb, exp, val);
+        put_bits(pb, exp + 1, val);
     } else if (rice_order) {
         mask = (1 << rice_order) - 1;
         put_bits(pb, (val >> rice_order), 0);
@@ -487,18 +488,14 @@ static int prores_encode_picture(AVCodecContext *avctx, AVFrame *pic,
 static int prores_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
                                const AVFrame *pict, int *got_packet)
 {
-    ProresContext* ctx = avctx->priv_data;
     int header_size = 148;
     uint8_t *buf;
     int pic_size, ret;
     int frame_size = FFALIGN(avctx->width, 16) * FFALIGN(avctx->height, 16)*16 + 500 + FF_MIN_BUFFER_SIZE; //FIXME choose tighter limit
 
 
-    if (!pkt->data &&
-        (ret = av_new_packet(pkt, frame_size + FF_MIN_BUFFER_SIZE)) < 0) {
-        av_log(avctx, AV_LOG_ERROR, "Error getting output packet.\n");
+    if ((ret = ff_alloc_packet2(avctx, pkt, frame_size + FF_MIN_BUFFER_SIZE)) < 0)
         return ret;
-    }
 
     buf = pkt->data;
     pic_size = prores_encode_picture(avctx, pict, buf + header_size + 8,