SPDIF and ticket #2277

Roberto Togni <[email protected]>
Newsgroups gmane.comp.video.mplayer.devel
Message-ID <[email protected]>
Hi,
 I'm looking into ticket #2277.
The file was already fixed for normal playback, but it still fails
with -ao null. In this case the ad_spdif decoder is invoked, and
crashes int lavf.

Tha attached patch fixes it, but I have no way to test this.

By looking at the change, I don't see any relation between my fix and
the fuzzed file; I suspect that spdif was just broken by some changes
in ffmpeg and nobody noticed.


Can anybody with spdif check if playback is broken with and without my
patch?
Bonus points if you also check the 1.2 branch.


Ciao,
 Roberto

_______________________________________________
MPlayer-dev-eng mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/mplayer-dev-eng
spdif_#2277.diff (text/x-patch, 1.6 KB)
Index: libmpcodecs/ad_spdif.c
===================================================================
--- libmpcodecs/ad_spdif.c	(revisione 37599)
+++ libmpcodecs/ad_spdif.c	(copia locale)
@@ -45,6 +45,7 @@
     int              out_buffer_size;
     uint8_t         *out_buffer;
     uint8_t          pb_buffer[OUTBUF_SIZE];
+    int              header_written;
 };
 
 static int read_packet(void *p, uint8_t *buf, int buf_size)
@@ -78,7 +79,7 @@
 
 static int init(sh_audio_t *sh)
 {
-    int i, x, in_size, srate, bps, *dtshd_rate;
+    int i, x, in_size, srate, bps, *dtshd_rate, res;
     unsigned char *start;
     double pts;
     static const struct {
@@ -129,11 +130,13 @@
             break;
         }
     }
-    if (AVERROR_PATCHWELCOME == lavf_ctx->oformat->write_header(lavf_ctx)) {
-        mp_msg(MSGT_DECAUDIO,MSGL_INFO,
+    if ((res = avformat_write_header(lavf_ctx, NULL)) < 0) {
+        if (res == AVERROR_PATCHWELCOME)
+            mp_msg(MSGT_DECAUDIO,MSGL_INFO,
                "This codec is not supported by spdifenc.\n");
         goto fail;
     }
+    spdif_ctx->header_written = 1;
 
     // get sample_rate & bitrate from parser
     x = ds_get_packet_pts(sh->ds, &start, &pts);
@@ -292,8 +295,8 @@
     AVFormatContext     *lavf_ctx  = spdif_ctx->lavf_ctx;
 
     if (lavf_ctx) {
-        if (lavf_ctx->oformat)
-            lavf_ctx->oformat->write_trailer(lavf_ctx);
+        if (spdif_ctx->header_written)
+            av_write_trailer(lavf_ctx);
         av_freep(&lavf_ctx->pb);
         if (lavf_ctx->streams) {
             av_freep(&lavf_ctx->streams[0]->codec);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.