Browse code

Use new function put_nbyte() to speed up padding.

Patch by Anssi Hannula, anssi d hannula a iki d fi

Originally committed as revision 26194 to svn://svn.ffmpeg.org/ffmpeg/trunk

Anssi Hannula authored on 2011/01/02 19:46:50
Showing 1 changed files
... ...
@@ -347,7 +347,7 @@ static int spdif_write_packet(struct AVFormatContext *s, AVPacket *pkt)
347 347
     if (!ctx->pkt_offset)
348 348
         return 0;
349 349
 
350
-    padding = (ctx->pkt_offset - ctx->use_preamble * BURST_HEADER_SIZE - ctx->out_bytes) >> 1;
350
+    padding = (ctx->pkt_offset - ctx->use_preamble * BURST_HEADER_SIZE - ctx->out_bytes) & ~1;
351 351
     if (padding < 0) {
352 352
         av_log(s, AV_LOG_ERROR, "bitrate is too high\n");
353 353
         return AVERROR(EINVAL);
... ...
@@ -373,8 +373,7 @@ static int spdif_write_packet(struct AVFormatContext *s, AVPacket *pkt)
373 373
     if (ctx->out_bytes & 1)
374 374
         put_be16(s->pb, ctx->out_buf[ctx->out_bytes - 1]);
375 375
 
376
-    for (; padding > 0; padding--)
377
-        put_be16(s->pb, 0);
376
+    put_nbyte(s->pb, 0, padding);
378 377
 
379 378
     av_log(s, AV_LOG_DEBUG, "type=%x len=%i pkt_offset=%i\n",
380 379
            ctx->data_type, ctx->out_bytes, ctx->pkt_offset);