]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/ralf.c
lavc: Add option to encode MPEG-2 AAC with libfdk-aac
[ffmpeg] / libavcodec / ralf.c
index 580def318345a0d00bc175ba44f084aafac05ea1..e78a9d442db6c45db5fe557e9ea299f28beb106e 100644 (file)
@@ -26,6 +26,7 @@
  * Dedicated to the mastermind behind it, Ralph Wiggum.
  */
 
+#include "libavutil/attributes.h"
 #include "libavutil/channel_layout.h"
 #include "avcodec.h"
 #include "get_bits.h"
@@ -49,8 +50,6 @@ typedef struct VLCSet {
 #define RALF_MAX_PKT_SIZE 8192
 
 typedef struct RALFContext {
-    AVFrame frame;
-
     int version;
     int max_frame_size;
     VLCSet sets[3];
@@ -74,7 +73,7 @@ typedef struct RALFContext {
 
 #define MAX_ELEMS 644 // no RALF table uses more than that
 
-static int init_ralf_vlc(VLC *vlc, const uint8_t *data, int elems)
+static av_cold int init_ralf_vlc(VLC *vlc, const uint8_t *data, int elems)
 {
     uint8_t  lens[MAX_ELEMS];
     uint16_t codes[MAX_ELEMS];
@@ -138,7 +137,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
 
     ctx->version = AV_RB16(avctx->extradata + 4);
     if (ctx->version != 0x103) {
-        av_log_ask_for_sample(avctx, "unknown version %X\n", ctx->version);
+        avpriv_request_sample(avctx, "Unknown version %X", ctx->version);
         return AVERROR_PATCHWELCOME;
     }
 
@@ -154,9 +153,6 @@ static av_cold int decode_init(AVCodecContext *avctx)
     avctx->channel_layout = (avctx->channels == 2) ? AV_CH_LAYOUT_STEREO
                                                    : AV_CH_LAYOUT_MONO;
 
-    avcodec_get_frame_defaults(&ctx->frame);
-    avctx->coded_frame = &ctx->frame;
-
     ctx->max_frame_size = AV_RB32(avctx->extradata + 16);
     if (ctx->max_frame_size > (1 << 20) || !ctx->max_frame_size) {
         av_log(avctx, AV_LOG_ERROR, "invalid frame size %d\n",
@@ -426,6 +422,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr,
                         AVPacket *avpkt)
 {
     RALFContext *ctx = avctx->priv_data;
+    AVFrame *frame   = data;
     int16_t *samples0;
     int16_t *samples1;
     int ret;
@@ -463,13 +460,13 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr,
         src_size = avpkt->size;
     }
 
-    ctx->frame.nb_samples = ctx->max_frame_size;
-    if ((ret = ff_get_buffer(avctx, &ctx->frame)) < 0) {
+    frame->nb_samples = ctx->max_frame_size;
+    if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) {
         av_log(avctx, AV_LOG_ERROR, "Me fail get_buffer()? That's unpossible!\n");
         return ret;
     }
-    samples0 = (int16_t *)ctx->frame.data[0];
-    samples1 = (int16_t *)ctx->frame.data[1];
+    samples0 = (int16_t *)frame->data[0];
+    samples1 = (int16_t *)frame->data[1];
 
     if (src_size < 5) {
         av_log(avctx, AV_LOG_ERROR, "too short packets are too short!\n");
@@ -511,9 +508,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr,
         bytes_left    -= ctx->block_size[i];
     }
 
-    ctx->frame.nb_samples = ctx->sample_offset;
-    *got_frame_ptr  = ctx->sample_offset > 0;
-    *(AVFrame*)data = ctx->frame;
+    frame->nb_samples = ctx->sample_offset;
+    *got_frame_ptr    = ctx->sample_offset > 0;
 
     return avpkt->size;
 }