[PATCH] transcode: port to FFmpeg-0.8 API

Dominik 'Rathann' Mierzejewski dominik at greysector.net
Sun Sep 4 00:07:53 CEST 2011


Attached.

-- 
Fedora http://fedoraproject.org/wiki/User:Rathann
RPMFusion http://rpmfusion.org | MPlayer http://mplayerhq.hu
"Faith manages."
        -- Delenn to Lennier in Babylon 5:"Confessions and Lamentations"
-------------- next part --------------
diff -up transcode-1.1.5/export/export_ffmpeg.c.ffmpeg transcode-1.1.5/export/export_ffmpeg.c
--- transcode-1.1.5/export/export_ffmpeg.c.ffmpeg	2009-02-21 22:01:57.000000000 +0100
+++ transcode-1.1.5/export/export_ffmpeg.c	2011-09-03 12:39:13.000000000 +0200
@@ -643,8 +643,10 @@ MOD_init
 
     lavc_venc_context->bit_rate           = vob->divxbitrate * 1000;
     lavc_venc_context->bit_rate_tolerance = lavc_param_vrate_tolerance * 1000;
+#if FF_API_MB_Q
     lavc_venc_context->mb_qmin            = lavc_param_mb_qmin;
     lavc_venc_context->mb_qmax            = lavc_param_mb_qmax;
+#endif
     lavc_venc_context->lmin= (int)(FF_QP2LAMBDA * lavc_param_lmin + 0.5);
     lavc_venc_context->lmax= (int)(FF_QP2LAMBDA * lavc_param_lmax + 0.5);
     lavc_venc_context->max_qdiff          = lavc_param_vqdiff;
diff -up transcode-1.1.5/filter/filter_resample.c.ffmpeg transcode-1.1.5/filter/filter_resample.c
--- transcode-1.1.5/filter/filter_resample.c.ffmpeg	2009-02-21 22:01:57.000000000 +0100
+++ transcode-1.1.5/filter/filter_resample.c	2011-09-03 13:28:13.000000000 +0200
@@ -110,8 +110,15 @@ static int resample_configure(TCModuleIn
         goto abort;
     }
 
+#if FF_API_AUDIO_OLD
     pd->resample_ctx = audio_resample_init(vob->a_chan, vob->a_chan,
                                            vob->mp3frequency, vob->a_rate);
+#else
+    pd->resample_ctx = av_audio_resample_init(vob->a_chan, vob->a_chan,
+                                           vob->mp3frequency, vob->a_rate,
+                                           AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16,
+                                           16, 10, 0, 0.8);
+#endif
     if (pd->resample_ctx == NULL) {
         tc_log_error(MOD_NAME, "can't get a resample context");
         goto abort;
diff -up transcode-1.1.5/import/decode_lavc.c.ffmpeg transcode-1.1.5/import/decode_lavc.c
--- transcode-1.1.5/import/decode_lavc.c.ffmpeg	2009-03-28 09:39:08.000000000 +0100
+++ transcode-1.1.5/import/decode_lavc.c	2011-09-03 12:39:13.000000000 +0200
@@ -261,8 +261,17 @@ void decode_lavc(decode_t *decode)
 
       //tc_log_msg(__FILE__, "SIZE: (%d) MP4(%d) blen(%d) BUF(%d) read(%ld)", len, mp4_size, buf_len, READ_BUFFER_SIZE, bytes_read);
       do {
+#if FF_API_VIDEO_OLD
 	  len = avcodec_decode_video(lavc_dec_context, &picture,
 		  &got_picture, buffer+buf_len, mp4_size-buf_len);
+#else
+	  AVPacket avpkt;
+	  av_init_packet(&avpkt);
+	  avpkt.data = buffer+buf_len;
+	  avpkt.size = mp4_size-buf_len;
+	  len = avcodec_decode_video2(lavc_dec_context, &picture,
+		  &got_picture, &avpkt);
+#endif
 
 	  if (len < 0) {
 	      tc_log_error(__FILE__, "frame decoding failed");
diff -up transcode-1.1.5/import/import_ffmpeg.c.ffmpeg transcode-1.1.5/import/import_ffmpeg.c
--- transcode-1.1.5/import/import_ffmpeg.c.ffmpeg	2009-02-21 22:01:57.000000000 +0100
+++ transcode-1.1.5/import/import_ffmpeg.c	2011-09-03 14:09:41.000000000 +0200
@@ -543,8 +543,17 @@ MOD_decode {
 retry:
     do {
       TC_LOCK_LIBAVCODEC;
+#if FF_API_VIDEO_OLD
       len = avcodec_decode_video(lavc_dec_context, &picture,
 			         &got_picture, buffer, bytes_read);
+#else
+      AVPacket avpkt;
+      av_init_packet(&avpkt);
+      avpkt.data = buffer;
+      avpkt.size = bytes_read;
+      len = avcodec_decode_video2(lavc_dec_context, &picture,
+			         &got_picture, &avpkt);
+#endif
       TC_UNLOCK_LIBAVCODEC;
 
       if (len < 0) {
diff -up transcode-1.1.5/import/probe_ffmpeg.c.ffmpeg transcode-1.1.5/import/probe_ffmpeg.c
--- transcode-1.1.5/import/probe_ffmpeg.c.ffmpeg	2009-03-28 09:39:08.000000000 +0100
+++ transcode-1.1.5/import/probe_ffmpeg.c	2011-09-03 12:39:13.000000000 +0200
@@ -47,7 +47,11 @@ static void translate_info(const AVForma
     for (i = 0; i < ctx->nb_streams; i++) {
         st = ctx->streams[i];
 
+#if LIBAVCODEC_VERSION_MAJOR < 53
         if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
+#else
+        if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
+#endif
             info->bitrate = st->codec->bit_rate / 1000;
             info->width = st->codec->width;
             info->height = st->codec->height;
@@ -65,7 +69,11 @@ static void translate_info(const AVForma
     for (i = 0; i < ctx->nb_streams; i++) {
         st = ctx->streams[i];
 
+#if LIBAVCODEC_VERSION_MAJOR < 53
         if (st->codec->codec_type == CODEC_TYPE_AUDIO
+#else
+        if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO
+#endif
          && j < TC_MAX_AUD_TRACKS) {
             info->track[j].format = 0x1; /* known wrong */
             info->track[j].chan = st->codec->channels;


More information about the rpmfusion-developers mailing list