]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
libav: Use newer version of LIBAV. Patch by IRC user 'kvaster'.
authorDreamcat4 <dreamcat4@gmail.com>
Tue, 5 Aug 2014 13:13:13 +0000 (14:13 +0100)
committerJaroslav Kysela <perex@perex.cz>
Wed, 6 Aug 2014 18:00:57 +0000 (20:00 +0200)
source: http://pastebin.com/fGLBsdqb
Many thanks / all credit to @kvaster

[12:15] < kvaster> I've made a patch for newer libav locally. Will be able to submit today a bit later.
[12:17] < kvaster> http://pastebin.com/fGLBsdqb
[12:23] < kvaster> it was just small api changes inside libav, I'm worried only about audio stream buffer sizes.
[12:24] < kvaster> Anyway this is working for me at least.

configure
src/libav.c
src/libav.h
src/plumbing/transcoding.c

index 1cc91c4e1fefa321b9945093ef69946c7e9376fb..0e3d2ec658e27bb6f509932994e2735a97f2e4d6 100755 (executable)
--- a/configure
+++ b/configure
@@ -245,7 +245,7 @@ fi
 if enabled_or_auto libav; then
   has_libav=true
 
-  if $has_libav && ! check_pkg libavcodec "<=55.0.0"; then
+  if $has_libav && ! check_pkg libavcodec "<=56.0.0"; then
     has_libav=false
   fi
 
@@ -257,7 +257,7 @@ if enabled_or_auto libav; then
     has_libav=false
   fi
 
-  if $has_libav && ! check_pkg libavformat "<=55.0.0"; then
+  if $has_libav && ! check_pkg libavformat "<=56.0.0"; then
     has_libav=false
   fi
 
index 85d12770725c5fe21d1724d6548a14a7d090d4d6..c12c33f4b657b06fb06aceae2670468c78cc2c28 100644 (file)
@@ -50,47 +50,47 @@ libav_log_callback(void *ptr, int level, const char *fmt, va_list vl)
 /**
  * Translate a component type to a libavcodec id
  */
-enum CodecID
+enum AVCodecID
 streaming_component_type2codec_id(streaming_component_type_t type)
 {
-  enum CodecID codec_id = CODEC_ID_NONE;
+  enum AVCodecID codec_id = AV_CODEC_ID_NONE;
 
   switch(type) {
   case SCT_H264:
-    codec_id = CODEC_ID_H264;
+    codec_id = AV_CODEC_ID_H264;
     break;
   case SCT_MPEG2VIDEO:
-    codec_id = CODEC_ID_MPEG2VIDEO;
+    codec_id = AV_CODEC_ID_MPEG2VIDEO;
     break;
   case SCT_VP8:
-    codec_id = CODEC_ID_VP8;
+    codec_id = AV_CODEC_ID_VP8;
     break;
   case SCT_AC3:
-    codec_id = CODEC_ID_AC3;
+    codec_id = AV_CODEC_ID_AC3;
     break;
   case SCT_EAC3:
-    codec_id = CODEC_ID_EAC3;
+    codec_id = AV_CODEC_ID_EAC3;
     break;
   case SCT_AAC:
-    codec_id = CODEC_ID_AAC;
+    codec_id = AV_CODEC_ID_AAC;
     break;
   case SCT_MPEG2AUDIO:
-    codec_id = CODEC_ID_MP2;
+    codec_id = AV_CODEC_ID_MP2;
     break;
   case SCT_VORBIS:
-    codec_id = CODEC_ID_VORBIS;
+    codec_id = AV_CODEC_ID_VORBIS;
     break;
   case SCT_DVBSUB:
-    codec_id = CODEC_ID_DVB_SUBTITLE;
+    codec_id = AV_CODEC_ID_DVB_SUBTITLE;
     break;
   case SCT_TEXTSUB:
-    codec_id = CODEC_ID_TEXT;
+    codec_id = AV_CODEC_ID_TEXT;
     break;
  case SCT_TELETEXT:
-    codec_id = CODEC_ID_DVB_TELETEXT;
+    codec_id = AV_CODEC_ID_DVB_TELETEXT;
     break;
   default:
-    codec_id = CODEC_ID_NONE;
+    codec_id = AV_CODEC_ID_NONE;
     break;
   }
 
@@ -102,45 +102,45 @@ streaming_component_type2codec_id(streaming_component_type_t type)
  * Translate a libavcodec id to a component type
  */
 streaming_component_type_t
-codec_id2streaming_component_type(enum CodecID id)
+codec_id2streaming_component_type(enum AVCodecID id)
 {
-  streaming_component_type_t type = CODEC_ID_NONE;
+  streaming_component_type_t type = AV_CODEC_ID_NONE;
 
   switch(id) {
-  case CODEC_ID_H264:
+  case AV_CODEC_ID_H264:
     type = SCT_H264;
     break;
-  case CODEC_ID_MPEG2VIDEO:
+  case AV_CODEC_ID_MPEG2VIDEO:
     type = SCT_MPEG2VIDEO;
     break;
-  case CODEC_ID_VP8:
+  case AV_CODEC_ID_VP8:
     type = SCT_VP8;
     break;
-  case CODEC_ID_AC3:
+  case AV_CODEC_ID_AC3:
     type = SCT_AC3;
     break;
-  case CODEC_ID_EAC3:
+  case AV_CODEC_ID_EAC3:
     type = SCT_EAC3;
     break;
-  case CODEC_ID_AAC:
+  case AV_CODEC_ID_AAC:
     type = SCT_AAC;
     break;
-  case CODEC_ID_MP2:
+  case AV_CODEC_ID_MP2:
     type = SCT_MPEG2AUDIO;
     break;
-  case CODEC_ID_VORBIS:
+  case AV_CODEC_ID_VORBIS:
     type = SCT_VORBIS;
     break;
-  case CODEC_ID_DVB_SUBTITLE:
+  case AV_CODEC_ID_DVB_SUBTITLE:
     type = SCT_DVBSUB;
     break;
-  case CODEC_ID_TEXT:
+  case AV_CODEC_ID_TEXT:
     type = SCT_TEXTSUB;
     break;
-  case CODEC_ID_DVB_TELETEXT:
+  case AV_CODEC_ID_DVB_TELETEXT:
     type = SCT_TELETEXT;
     break;
-  case CODEC_ID_NONE:
+  case AV_CODEC_ID_NONE:
     type = SCT_NONE;
     break;
   default:
index d34412d4c9bc5c223e5d8683b9de188bde744945..5217c5f0d564bf15ad8c25b5045d6c1e18fc65db 100644 (file)
@@ -23,8 +23,8 @@
 #include <libavformat/avformat.h>
 #include "tvheadend.h"
 
-enum CodecID streaming_component_type2codec_id(streaming_component_type_t type);
-streaming_component_type_t codec_id2streaming_component_type(enum CodecID id);
+enum AVCodecID streaming_component_type2codec_id(streaming_component_type_t type);
+streaming_component_type_t codec_id2streaming_component_type(enum AVCodecID id);
 int libav_is_encoder(AVCodec *codec);
 void libav_init(void);
 
index e1b1c599b26e00bd7f1a9500e805d511db9cb436..b55756372f95839af0fdff8194aaa522187a2ab6 100644 (file)
@@ -108,9 +108,9 @@ typedef struct transcoder {
 
 
 
-#define WORKING_ENCODER(x) (x == CODEC_ID_H264 || x == CODEC_ID_MPEG2VIDEO || \
-                           x == CODEC_ID_VP8  || x == CODEC_ID_AAC ||  \
-                           x == CODEC_ID_MP2  || x == CODEC_ID_VORBIS)
+#define WORKING_ENCODER(x) (x == AV_CODEC_ID_H264 || x == AV_CODEC_ID_MPEG2VIDEO || \
+                           x == AV_CODEC_ID_VP8  || x == AV_CODEC_ID_AAC ||    \
+                           x == AV_CODEC_ID_MP2  || x == AV_CODEC_ID_VORBIS)
 
 
 uint32_t transcoding_enabled = 0;
@@ -121,11 +121,11 @@ uint32_t transcoding_enabled = 0;
 static AVCodec *
 transcoder_get_decoder(streaming_component_type_t ty)
 {
-  enum CodecID codec_id;
+  enum AVCodecID codec_id;
   AVCodec *codec;
 
   codec_id = streaming_component_type2codec_id(ty);
-  if (codec_id == CODEC_ID_NONE) {
+  if (codec_id == AV_CODEC_ID_NONE) {
     tvhlog(LOG_ERR, "transcode", "Unsupported input codec %s", 
           streaming_component_type2txt(ty));
     return NULL;
@@ -150,11 +150,11 @@ transcoder_get_decoder(streaming_component_type_t ty)
 static AVCodec *
 transcoder_get_encoder(streaming_component_type_t ty)
 {
-  enum CodecID codec_id;
+  enum AVCodecID codec_id;
   AVCodec *codec;
 
   codec_id = streaming_component_type2codec_id(ty);
-  if (codec_id == CODEC_ID_NONE) {
+  if (codec_id == AV_CODEC_ID_NONE) {
     tvhlog(LOG_ERR, "transcode", "Unable to find %s codec", 
           streaming_component_type2txt(ty));
     return NULL;
@@ -214,7 +214,7 @@ transcoder_stream_subtitle(transcoder_stream_t *ts, th_pkt_t *pkt)
   icodec = ss->sub_icodec;
   //ocodec = ss->sub_ocodec;
 
-  if (ictx->codec_id == CODEC_ID_NONE) {
+  if (ictx->codec_id == AV_CODEC_ID_NONE) {
     ictx->codec_id = icodec->id;
 
     if (avcodec_open2(ictx, icodec, NULL) < 0) {
@@ -272,7 +272,7 @@ transcoder_stream_audio(transcoder_stream_t *ts, th_pkt_t *pkt)
   icodec = as->aud_icodec;
   ocodec = as->aud_ocodec;
 
-  if (ictx->codec_id == CODEC_ID_NONE) {
+  if (ictx->codec_id == AV_CODEC_ID_NONE) {
     ictx->codec_id = icodec->id;
 
     if (avcodec_open2(ictx, icodec, NULL) < 0) {
@@ -391,7 +391,7 @@ transcoder_stream_audio(transcoder_stream_t *ts, th_pkt_t *pkt)
     break;
   }
 
-  if (octx->codec_id == CODEC_ID_NONE) {
+  if (octx->codec_id == AV_CODEC_ID_NONE) {
     octx->codec_id = ocodec->id;
 
     if (avcodec_open2(octx, ocodec, NULL) < 0) {
@@ -478,7 +478,7 @@ transcoder_stream_video(transcoder_stream_t *ts, th_pkt_t *pkt)
   buf = out = deint = NULL;
   opts = NULL;
 
-  if (ictx->codec_id == CODEC_ID_NONE) {
+  if (ictx->codec_id == AV_CODEC_ID_NONE) {
     ictx->codec_id = icodec->id;
 
     if (avcodec_open2(ictx, icodec, NULL) < 0) {
@@ -523,7 +523,7 @@ transcoder_stream_video(transcoder_stream_t *ts, th_pkt_t *pkt)
   vs->vid_enc_frame->sample_aspect_ratio.num = vs->vid_dec_frame->sample_aspect_ratio.num;
   vs->vid_enc_frame->sample_aspect_ratio.den = vs->vid_dec_frame->sample_aspect_ratio.den;
 
-  if(octx->codec_id == CODEC_ID_NONE) {
+  if(octx->codec_id == AV_CODEC_ID_NONE) {
     // Common settings
     octx->width           = vs->vid_width  ? vs->vid_width  : ictx->width;
     octx->height          = vs->vid_height ? vs->vid_height : ictx->height;
@@ -534,7 +534,7 @@ transcoder_stream_video(transcoder_stream_t *ts, th_pkt_t *pkt)
 
     switch (ts->ts_type) {
     case SCT_MPEG2VIDEO:
-      octx->codec_id       = CODEC_ID_MPEG2VIDEO;
+      octx->codec_id       = AV_CODEC_ID_MPEG2VIDEO;
       octx->pix_fmt        = PIX_FMT_YUV420P;
       octx->flags         |= CODEC_FLAG_GLOBAL_HEADER;
 
@@ -547,7 +547,7 @@ transcoder_stream_video(transcoder_stream_t *ts, th_pkt_t *pkt)
       break;
  
     case SCT_VP8:
-      octx->codec_id       = CODEC_ID_VP8;
+      octx->codec_id       = AV_CODEC_ID_VP8;
       octx->pix_fmt        = PIX_FMT_YUV420P;
 
       octx->qmin = 10;
@@ -561,7 +561,7 @@ transcoder_stream_video(transcoder_stream_t *ts, th_pkt_t *pkt)
       break;
 
     case SCT_H264:
-      octx->codec_id       = CODEC_ID_H264;
+      octx->codec_id       = AV_CODEC_ID_H264;
       octx->pix_fmt        = PIX_FMT_YUV420P;
       octx->flags          |= CODEC_FLAG_GLOBAL_HEADER;
 
@@ -951,8 +951,8 @@ transcoder_init_audio(transcoder_t *t, streaming_start_component_t *ssc)
   as->aud_ictx->thread_count = sysconf(_SC_NPROCESSORS_ONLN);
   as->aud_octx->thread_count = sysconf(_SC_NPROCESSORS_ONLN);
 
-  as->aud_dec_size = AVCODEC_MAX_AUDIO_FRAME_SIZE*2;
-  as->aud_enc_size = AVCODEC_MAX_AUDIO_FRAME_SIZE*2;
+  as->aud_dec_size = 192000*2;
+  as->aud_enc_size = 192000*2;
 
   as->aud_dec_sample = av_malloc(as->aud_dec_size + FF_INPUT_BUFFER_PADDING_SIZE);
   as->aud_enc_sample = av_malloc(as->aud_enc_size + FF_INPUT_BUFFER_PADDING_SIZE);