]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/adpcmenc.c
aarch64: h264pred: Optimize the inner loop of existing 8 bit functions
[ffmpeg] / libavcodec / adpcmenc.c
index 78600735cf283388d5061d8ba28aa764051c91d0..9dc77d519ad5b1126a963d8cf2596f4fdaa601e2 100644 (file)
@@ -722,6 +722,9 @@ static int adpcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
 
         n = frame->nb_samples - 1;
 
+        /* NB: This is safe as we don't have AV_CODEC_CAP_SMALL_LAST_FRAME. */
+        av_assert0(n == 4095);
+
         // store AdpcmCodeSize
         put_bits(&pb, 2, 2);    // set 4-bit flash adpcm format
 
@@ -735,8 +738,7 @@ static int adpcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
         }
 
         if (avctx->trellis > 0) {
-            if (!(buf = av_malloc(2 * n)))
-                return AVERROR(ENOMEM);
+            uint8_t buf[8190 /* = 2 * n */];
             adpcm_compress_trellis(avctx, samples + avctx->channels, buf,
                                    &c->status[0], n, avctx->channels);
             if (avctx->channels == 2)
@@ -748,7 +750,6 @@ static int adpcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
                 if (avctx->channels == 2)
                     put_bits(&pb, 4, buf[n + i]);
             }
-            av_free(buf);
         } else {
             for (i = 1; i < frame->nb_samples; i++) {
                 put_bits(&pb, 4, adpcm_ima_compress_sample(&c->status[0],
@@ -959,14 +960,14 @@ static const AVOption options[] = {
     { NULL }
 };
 
-static const AVClass adpcm_encoder_class = {
-    .class_name = "ADPCM Encoder",
-    .item_name  = av_default_item_name,
-    .option     = options,
-    .version    = LIBAVUTIL_VERSION_INT,
-};
-
 #define ADPCM_ENCODER(id_, name_, sample_fmts_, capabilities_, long_name_) \
+static const AVClass name_ ## _encoder_class = {                           \
+    .class_name = #name_,                                                  \
+    .item_name  = av_default_item_name,                                    \
+    .option     = options,                                                 \
+    .version    = LIBAVUTIL_VERSION_INT,                                   \
+};                                                                         \
+                                                                           \
 AVCodec ff_ ## name_ ## _encoder = {                                       \
     .name           = #name_,                                              \
     .long_name      = NULL_IF_CONFIG_SMALL(long_name_),                    \
@@ -979,7 +980,7 @@ AVCodec ff_ ## name_ ## _encoder = {                                       \
     .sample_fmts    = sample_fmts_,                                        \
     .capabilities   = capabilities_,                                       \
     .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_INIT_THREADSAFE, \
-    .priv_class     = &adpcm_encoder_class,                                \
+    .priv_class     = &name_ ## _encoder_class,                            \
 }
 
 ADPCM_ENCODER(AV_CODEC_ID_ADPCM_ARGO,    adpcm_argo,    sample_fmts_p, 0,                             "ADPCM Argonaut Games");