Re: Recording DVB-T HD infrance

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



El Miércoles, 17 de Marzo de 2010, Eric Valette escribió:
> >> Still wonder why such a one liner patch is not integrated though.
> > 
> > That forum is in French and apparently requires registration.
> > 
> > Can you post that "one-liner" here?
> 
> I just translate the instruction, into english (could do german too ;-))
> Could do a diff but for one trivial line no need for it.
> 
> Just add the following line in pat.c
> 
> case SI::AC3DescriptorTag:
> + case SI::EnhancedAC3DescriptorTag:
> dpid = stream.getPid();
> 
> 
> 
> I think for streamdev the same patch is required in
> livestreamer.c
> 
> case SI::AC3DescriptorTag:
> + case SI::EnhancedAC3DescriptorTag:
> Dprintf("cStreamdevPatFilter PMT scanner: adding PID %d (%s) %s\n",
> 
> -- eric
> 
> 
> 

I make a patch to use ffmpeg eac3 with xine. The patch is for the latest xine-
lib-1.2 hg. If you use xineliboutput you also need the second  patch attached.

Jose Alberto
diff -r a6a25ea3e2c8 src/combined/ffmpeg/ff_audio_decoder.c
--- a/src/combined/ffmpeg/ff_audio_decoder.c	Sun Mar 14 15:12:25 2010 +0000
+++ b/src/combined/ffmpeg/ff_audio_decoder.c	Thu Mar 18 21:56:24 2010 +0100
@@ -68,6 +68,8 @@
 
   char              *decode_buffer;
   int               decoder_ok;
+  int               sync;
+  int               frame_size;
 
 } ff_audio_decoder_t;
 
@@ -257,10 +259,46 @@
 
     if( !this->decoder_ok ) {
       if ( ! this->context || ! this->codec ) {
-        xprintf (this->stream->xine, XINE_VERBOSITY_LOG,
-		_("ffmpeg_audio_dec: trying to open null codec\n"));
-	_x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_HANDLED, 0);
-	return;
+	if ( (buf->type & 0xFFFF0000) == BUF_AUDIO_A52 ) { 
+	pthread_mutex_lock (&ffmpeg_lock);
+        this->codec = avcodec_find_decoder(CODEC_ID_AC3);
+	pthread_mutex_unlock (&ffmpeg_lock);
+        _x_meta_info_set(this->stream, XINE_META_INFO_AUDIOCODEC,
+                           "AC3 coque (ffmpeg)");
+
+        if (!this->codec) {
+          xprintf (this->stream->xine, XINE_VERBOSITY_LOG,
+                   _("ffmpeg_audio_dec: couldn't find ffmpeg decoder for buf type 0x%X\n"),
+                   buf->type);
+          _x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_HANDLED, 0);
+          return;
+        }
+
+        this->context = avcodec_alloc_context();
+
+        this->audio_bits = 16;
+//	this->audio_sample_rate = 48000;
+//	this->audio_channels = 6;	
+//	this->frame_size = 768;
+        this->context->request_channels = 2;
+
+        this->context->bits_per_sample = this->audio_bits;
+        this->context->sample_rate = this->audio_sample_rate;
+        this->context->channels    = this->audio_channels;
+        this->context->codec_id    = this->codec->id;
+        this->context->codec_type  = this->codec->type;
+        this->context->codec_tag   = _x_stream_info_get(this->stream, XINE_STREAM_INFO_AUDIO_FOURCC);
+
+        this->size = 0;
+	this->sync = 0;
+
+        this->decode_buffer = calloc(1, AVCODEC_MAX_AUDIO_FRAME_SIZE);
+	} else {
+       	  xprintf (this->stream->xine, XINE_VERBOSITY_LOG,
+		  _("ffmpeg_audio_dec: trying to open null codec\n"));
+	  _x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_HANDLED, 0);
+	  return;
+	}
       }
 
       pthread_mutex_lock (&ffmpeg_lock);
@@ -278,20 +316,32 @@
     if( buf->decoder_flags & BUF_FLAG_PREVIEW )
       return;
 
+    if (this->sync == 0) {
+      while ((buf->content[0] != 0x0b) || (buf->content[1] != 0x77)) {
+        buf->content++;
+	buf->size--;
+      }
+      this->sync = 1;
+    }
     ff_audio_ensure_buffer_size(this, this->size + buf->size);
     xine_fast_memcpy (&this->buf[this->size], buf->content, buf->size);
     this->size += buf->size;
 
     if (!this->output_open) {
+//      if ((!this->audio_bits || !this->audio_sample_rate || !this->audio_channels) || ( (buf->type & 0xFFFF0000) == BUF_AUDIO_A52 )) {
       if (!this->audio_bits || !this->audio_sample_rate || !this->audio_channels) {
-        avcodec_decode_audio2 (this->context,
+	decode_buffer_size = AVCODEC_MAX_AUDIO_FRAME_SIZE;
+        this->frame_size = avcodec_decode_audio2 (this->context,
                               (int16_t *)this->decode_buffer,
                               &decode_buffer_size,
                               &this->buf[0],
                               this->size);
+//	this->size -= this->frame_size;
+//	memmove(this->buf, &this->buf[this->frame_size], this->size);
 	this->audio_bits = this->context->bits_per_sample;
 	this->audio_sample_rate = this->context->sample_rate;
 	this->audio_channels = this->context->channels;
+//printf ("COQUE %d %d %d %d\n", this->audio_bits, this->audio_sample_rate, this->audio_channels, this->frame_size);
 	if (!this->audio_bits || !this->audio_sample_rate || !this->audio_channels)
 	  return;
       }
@@ -304,10 +354,10 @@
     if (!this->output_open)
       return;
 
-    if (buf->decoder_flags & BUF_FLAG_FRAME_END)  { /* time to decode a frame */
+    if ((((buf->type & 0xFFFF0000) != BUF_AUDIO_A52 ) && (buf->decoder_flags & BUF_FLAG_FRAME_END)) || ((buf->type & 0xFFFF0000) == BUF_AUDIO_A52 ))  { /* time to decode a frame */
 
       offset = 0;
-      while (this->size>0) {
+      while (((this->size>0) && ((buf->type & 0xFFFF0000) != BUF_AUDIO_A52)) || (((buf->type & 0xFFFF0000) == BUF_AUDIO_A52) && (this->size>=this->frame_size))) {
         decode_buffer_size = AVCODEC_MAX_AUDIO_FRAME_SIZE;
         bytes_consumed = avcodec_decode_audio2 (this->context,
                                                (int16_t *)this->decode_buffer,
@@ -315,10 +365,12 @@
                                                &this->buf[offset],
                                                this->size);
 
+	this->frame_size = bytes_consumed;
         if (bytes_consumed<0) {
           xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG,
                    "ffmpeg_audio_dec: error decompressing audio frame\n");
           this->size=0;
+          this->sync = 0;
           return;
         } else if (bytes_consumed == 0 && decode_buffer_size == 0) {
           if (offset)
@@ -333,6 +385,7 @@
 
 	  if (stream_status == XINE_STATUS_QUIT || stream_status == XINE_STATUS_STOP) {
 	    this->size = 0;
+	    this->sync = 0;
             return;
 	  }
 
@@ -388,7 +441,12 @@
       }
 
       /* reset internal accumulation buffer */
-      this->size = 0;
+      if ( (buf->type & 0xFFFF0000) != BUF_AUDIO_A52 )
+        this->size = 0;
+      else {
+          if (offset)
+            memmove(this->buf, &this->buf[offset], this->size);
+      }
     }
   }
 }
@@ -397,6 +455,7 @@
   ff_audio_decoder_t *this = (ff_audio_decoder_t *) this_gen;
 
   this->size = 0;
+  this->sync = 0;
 
   /* try to reset the wma decoder */
   if( this->context && this->decoder_ok ) {
@@ -455,6 +514,7 @@
   this->size = 0;
   this->bufsize = 0;
   this->decoder_ok = 0;
+  this->sync = 0;
 
   ff_audio_ensure_buffer_size(this, AUDIOBUFSIZE);
 
diff -r a6a25ea3e2c8 src/combined/ffmpeg/xine_audio.list
--- a/src/combined/ffmpeg/xine_audio.list	Sun Mar 14 15:12:25 2010 +0000
+++ b/src/combined/ffmpeg/xine_audio.list	Thu Mar 18 21:56:24 2010 +0100
@@ -40,10 +40,10 @@
 WAVPACK			WAVPACK			WavPack
 AMR_NB			AMR_NB			AMR narrow band
 AMR_WB			AMR_WB			AMR wide band
+A52			AC3			AC3 coque
 
 # disabled codecs (ref. configure.ac)
 !			AAC
-!			AC3
 !			ADPCM_ADX
 !			ADPCM_G726
 !			DSICINAUDIO
diff -r a6a25ea3e2c8 src/demuxers/demux_ts.c
--- a/src/demuxers/demux_ts.c	Sun Mar 14 15:12:25 2010 +0000
+++ b/src/demuxers/demux_ts.c	Thu Mar 18 21:56:24 2010 +0100
@@ -1415,9 +1415,9 @@
       break;
     case ISO_13818_PES_PRIVATE:
       for (i = 5; i < coded_length; i += stream[i+1] + 2) {
-          if ((stream[i] == 0x6a) && (this->audio_tracks_count < MAX_AUDIO_TRACKS)) {
-          int i, found = 0;
-          for(i = 0; i < this->audio_tracks_count; i++) {
+          if (((stream[i] == 0x6a) || (stream[i] == 0x7a)) && (this->audio_tracks_count < MAX_AUDIO_TRACKS)) {
+          int j, found = 0;
+          for(j = 0; j < this->audio_tracks_count; j++) {
             if(this->audio_tracks[i].pid == pid) {
               found = 1;
               break;
@@ -1427,8 +1427,12 @@
 #ifdef TS_PMT_LOG
             printf ("demux_ts: PMT AC3 audio pid 0x%.4x type %2.2x\n", pid, stream[0]);
 #endif
-          demux_ts_pes_new(this, this->media_num, pid,
-                           this->audio_fifo, STREAM_AUDIO_AC3);
+          if (stream[i] == 0x6a)
+            demux_ts_pes_new(this, this->media_num, pid,
+                             this->audio_fifo, STREAM_AUDIO_AC3);
+          else
+            demux_ts_pes_new(this, this->media_num, pid,
+                             this->audio_fifo, HDMV_AUDIO_84_EAC3);
 
           this->audio_tracks[this->audio_tracks_count].pid = pid;
           this->audio_tracks[this->audio_tracks_count].media_index = this->media_num;
Index: tools/ts.c
===================================================================
RCS file: /cvsroot/xineliboutput/vdr-xineliboutput/tools/ts.c,v
retrieving revision 1.21
diff -r1.21 ts.c
383c383
<           if ((stream[i] == STREAM_DESCR_AC3) && (pmt->audio_tracks_count < TS_MAX_AUDIO_TRACKS)) {
---
>           if (((stream[i] == STREAM_DESCR_AC3) || (stream[i] == STREAM_DESCR_EAC3))  && (pmt->audio_tracks_count < TS_MAX_AUDIO_TRACKS)) {
387c387,390
<               pmt->audio_tracks[pmt->audio_tracks_count].type = STREAM_AUDIO_AC3;
---
>               if (stream[i] == STREAM_DESCR_AC3)
>                 pmt->audio_tracks[pmt->audio_tracks_count].type = STREAM_AUDIO_AC3;
>               else
>                 pmt->audio_tracks[pmt->audio_tracks_count].type = STREAM_AUDIO_EAC3;
Index: tools/ts.h
===================================================================
RCS file: /cvsroot/xineliboutput/vdr-xineliboutput/tools/ts.h,v
retrieving revision 1.13
diff -r1.13 ts.h
78a79
>   STREAM_AUDIO_EAC3      = 0x84,
83a85
> #define STREAM_DESCR_EAC3   0x7a
_______________________________________________
vdr mailing list
vdr@xxxxxxxxxxx
http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr

[Index of Archives]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Util Linux NG]     [Xfree86]     [Big List of Linux Books]     [Fedora Users]     [Fedora Women]     [ALSA Devel]     [Linux USB]

  Powered by Linux