[FFmpeg-devel] [PATCH] [WIP] Updated MLP encoder - Qualification Task (TrueHD)

Rostislav Pehlivanov atomnuker at gmail.com
Thu Apr 7 03:27:24 CEST 2016


On 5 April 2016 at 22:25, Jai Luthra <me at jailuthra.in> wrote:

> Hi,
>
>
Patch had some problems - it's still using the very outdated encode frame
function definition, here's a fix for it:

You'll now get an output without crashes at a constant bitrate which kinda
decodes to just a square wave, with surprisingly no invalid bitstream
warnings, just lossless check failures (which happen with normal samples
when seeking as well).
No idea what's wrong yet, will try to solve it tomorrow. Might have
something to do with the apply_filter function.

diff --git a/libavcodec/mlpenc.c b/libavcodec/mlpenc.c
index 815b889..0f1c965 100644
--- a/libavcodec/mlpenc.c
+++ b/libavcodec/mlpenc.c
@@ -20,6 +20,7 @@
  */

 #include "avcodec.h"
+#include "internal.h"
 #include "put_bits.h"
 #include "libavutil/crc.h"
 #include "libavutil/avstring.h"
@@ -1872,7 +1873,7 @@ static int apply_filter(MLPEncodeContext *ctx,
unsigned int channel)

     for (i = 0; i < NUM_FILTERS; i++) {
         unsigned int size = ctx->number_of_samples;
-        filter_state_buffer[i] = av_malloc(size);
+        filter_state_buffer[i] = av_malloc(size*sizeof(int32_t));
     }

     for (i = 0; i < 8; i++) {
@@ -2267,12 +2268,23 @@ static void process_major_frame(MLPEncodeContext
*ctx)

 /****************************************************************************/

-static int mlp_encode_frame(AVCodecContext *avctx, uint8_t *buf, int
buf_size,
-                            void *data)
+static int mlp_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
+                            const AVFrame *frame, int *got_packet)
 {
     MLPEncodeContext *ctx = avctx->priv_data;
     unsigned int bytes_written = 0;
-    int restart_frame;
+    int restart_frame, ret, buf_size;
+    uint8_t *data, *buf;
+
+    if ((ret = ff_alloc_packet2(avctx, avpkt, 87500 * avctx->channels, 0))
< 0)
+        return ret;
+
+    if (!frame)
+        return 1;
+
+    data = frame->data[0];
+    buf = avpkt->data;
+    buf_size = avpkt->size;

     ctx->frame_index = avctx->frame_number % ctx->max_restart_interval;

@@ -2392,6 +2404,10 @@ input_and_return:

 no_data_left:

+    avpkt->size = bytes_written;
+
+    *got_packet = 1;
+
     return bytes_written;
 }


More information about the ffmpeg-devel mailing list