summaryrefslogtreecommitdiff
path: root/convert.c
diff options
context:
space:
mode:
authorJoerg Bornkessel <hd_brummy@gentoo.org>2014-11-05 23:56:11 +0100
committerJoerg Bornkessel <hd_brummy@gentoo.org>2014-11-05 23:56:11 +0100
commit8fcaa38795a8211205c3521f420850746bd1beb3 (patch)
treec8402928db64f3021a4ba3f3b0e5ae7a27ea04f0 /convert.c
parentc7abc470825c52167dd704322720566c10e78c76 (diff)
downloadvdr-plugin-audiorecorder-8fcaa38795a8211205c3521f420850746bd1beb3.tar.gz
vdr-plugin-audiorecorder-8fcaa38795a8211205c3521f420850746bd1beb3.tar.bz2
improvements avcodec_encode_audio2
Diffstat (limited to 'convert.c')
-rw-r--r--convert.c40
1 files changed, 33 insertions, 7 deletions
diff --git a/convert.c b/convert.c
index 526f4d5..4cb4fc5 100644
--- a/convert.c
+++ b/convert.c
@@ -112,7 +112,7 @@ void cConvert::decode_mpa_frame(mpeg_audio_frame *mpa_frame)
return;
}
-#ifndef AVCODEC_NEW
+//#ifndef AVCODEC_NEW
AVPacket avpkt;
av_init_packet(&avpkt);
avpkt.data = mpa_frame->data;
@@ -120,11 +120,11 @@ void cConvert::decode_mpa_frame(mpeg_audio_frame *mpa_frame)
decoder_buf.length = AVCODEC_MAX_AUDIO_FRAME_SIZE;
int len = avcodec_decode_audio3(decoder_ctx, (short *)decoder_buf.data,
&decoder_buf.length, &avpkt);
-#else
-#error "avcodec_decode_audio4 not implemented yet!"
+//#else
+//#error "avcodec_decode_audio4 not implemented yet!"
// ToDo
-#endif
+//#endif
}
@@ -161,9 +161,35 @@ abuffer *cConvert::reencode_mpa_frame(mpeg_audio_frame *mpa_frame,
encoder_buf.length, (short *)decoder_buf.data);
/* encoder_buf.offset is used to save the size of the encoded frame */
#else
-#error "avcodec_encode_audio2 not imlemented yet!"
-// ToDo
-
+//#error "avcodec_encode_audio2 not imlemented yet!"
+// https://www.ffmpeg.org/doxygen/1.0/group__lavc__encoding.html#gf12a9da0d33f50ff406e03572fab4763
+// https://www.ffmpeg.org/doxygen/1.0/decoding__encoding_8c-source.html#l00102
+/* int avcodec_encode_audio2
+ (
+ AVCodecContext * avctx,
+ AVPacket * avpkt,
+ const AVFrame * frame,
+ int * got_packet_ptr
+ ) */
+ AVFrame *frame;
+ AVPacket avpkt;
+ av_init_packet(&avpkt);
+ avpkt.data = map_frame->data;
+ avpkt.size = map_frame->size;
+ int got_output;
+
+ /* frame containing input raw audio */
+ frame = avcodec_alloc_frame();
+ if (!frame) {
+ fprintf(stderr, "Could not allocate audio frame\n");
+ exit(1);
+ }
+
+ encoder_buf.offset = avcodec_encode_audio2(encoder_ctx, &avpkt, frame, &got_output);
+ if (ret < 0) {
+ fprintf(stderr, "Error encoding audio frame\n");
+ exit(1);
+ }
#endif
return &encoder_buf;
}