[FFmpeg-soc] [soc]: r4977 - spdif/spdif.c

bwolowiec subversion at mplayerhq.hu
Fri Aug 7 19:35:59 CEST 2009


Author: bwolowiec
Date: Fri Aug  7 19:35:59 2009
New Revision: 4977

Log:
Earlier bitrate check.

Modified:
   spdif/spdif.c

Modified: spdif/spdif.c
==============================================================================
--- spdif/spdif.c	Fri Aug  7 19:23:11 2009	(r4976)
+++ spdif/spdif.c	Fri Aug  7 19:35:59 2009	(r4977)
@@ -204,13 +204,19 @@ static int spdif_write_header(AVFormatCo
 static int spdif_write_packet(struct AVFormatContext *s, AVPacket *pkt)
 {
     IEC958Context *ctx = s->priv_data;
-    int i, ret;
+    int ret, padding;
 
     ctx->pkt_size = ((pkt->size + 1) >> 1) << 4;
     ret = (*ctx->header_info) (s, pkt);
     if (ret < 0)
         return -1;
 
+    padding = (ctx->pkt_offset - BURST_HEADER_SIZE - pkt->size) >> 1;
+    if (padding < 0) {
+        av_log(s, AV_LOG_ERROR, "bitrate is too high\n");
+        return -1;
+    }
+
     put_le16(s->pb, SYNCWORD1);      //Pa
     put_le16(s->pb, SYNCWORD2);      //Pb
     put_le16(s->pb, ctx->data_type); //Pc
@@ -222,6 +228,7 @@ static int spdif_write_packet(struct AVF
     {
         //XXX swab... ?
         uint16_t *data = (uint16_t *) pkt->data;
+        int i;
         for (i = 0; i < pkt->size >> 1; i++)
             put_be16(s->pb, data[i]);
     }
@@ -230,13 +237,7 @@ static int spdif_write_packet(struct AVF
     if (pkt->size & 1)
         put_be16(s->pb, pkt->data[pkt->size - 1]);
 
-    i = (ctx->pkt_offset - BURST_HEADER_SIZE - pkt->size) >> 1;
-    if (i < 0) {
-        av_log(s, AV_LOG_ERROR, "bitrate is too high\n");
-        return -1;
-    }
-
-    for (; i > 0; i--)
+    for (; padding > 0; padding--)
         put_le16(s->pb, 0);
 
     av_log(s, AV_LOG_DEBUG, "type=%x len=%i pkt_offset=%i\n",


More information about the FFmpeg-soc mailing list