]> git.sesse.net Git - ffmpeg/commitdiff
Merge commit '62cc8f4d79dad119e8efeaae080a58a8dcb1e89d'
authorHendrik Leppkes <h.leppkes@gmail.com>
Sun, 29 Nov 2015 14:44:44 +0000 (15:44 +0100)
committerHendrik Leppkes <h.leppkes@gmail.com>
Sun, 29 Nov 2015 14:44:44 +0000 (15:44 +0100)
* commit '62cc8f4d79dad119e8efeaae080a58a8dcb1e89d':
  sgienc: Port to bytestream2

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
1  2 
libavcodec/sgienc.c

index b172835263911e9da2febbf6496963935d241d15,a449f8c03b2569d09b963e31401df9611b5de1fa..4477fe1d1a174e8cc616c9a887d13819fb0a19dc
@@@ -114,42 -113,45 +114,43 @@@ FF_ENABLE_DEPRECATION_WARNING
      else // assume ff_rl_encode() produces at most 2x size of input
          length += tablesize * 2 + depth * height * (2 * width + 1);
  
 -    if ((ret = ff_alloc_packet(pkt, bytes_per_channel * length)) < 0) {
 -        av_log(avctx, AV_LOG_ERROR, "Error getting output packet of size %d.\n", length);
 +    if ((ret = ff_alloc_packet2(avctx, pkt, bytes_per_channel * length, 0)) < 0)
          return ret;
-     buf     = pkt->data;
-     end_buf = pkt->data + pkt->size;
 -    }
+     bytestream2_init_writer(&pbc, pkt->data, pkt->size);
  
      /* Encode header. */
-     bytestream_put_be16(&buf, SGI_MAGIC);
-     bytestream_put_byte(&buf, avctx->coder_type != FF_CODER_TYPE_RAW); /* RLE 1 - VERBATIM 0*/
-     bytestream_put_byte(&buf, bytes_per_channel);
-     bytestream_put_be16(&buf, dimension);
-     bytestream_put_be16(&buf, width);
-     bytestream_put_be16(&buf, height);
-     bytestream_put_be16(&buf, depth);
-     bytestream_put_be32(&buf, 0L); /* pixmin */
-     bytestream_put_be32(&buf, pixmax);
-     bytestream_put_be32(&buf, 0L); /* dummy */
+     bytestream2_put_be16(&pbc, SGI_MAGIC);
+     bytestream2_put_byte(&pbc, avctx->coder_type != FF_CODER_TYPE_RAW); /* RLE 1 - VERBATIM 0 */
+     bytestream2_put_byte(&pbc, bytes_per_channel);
+     bytestream2_put_be16(&pbc, dimension);
+     bytestream2_put_be16(&pbc, width);
+     bytestream2_put_be16(&pbc, height);
+     bytestream2_put_be16(&pbc, depth);
+     bytestream2_put_be32(&pbc, 0L); /* pixmin */
+     bytestream2_put_be32(&pbc, pixmax);
+     bytestream2_put_be32(&pbc, 0L); /* dummy */
  
      /* name */
-     memset(buf, 0, SGI_HEADER_SIZE);
-     buf += 80;
+     bytestream2_skip_p(&pbc, 80);
  
      /* colormap */
-     bytestream_put_be32(&buf, 0L);
+     bytestream2_put_be32(&pbc, 0L);
  
      /* The rest of the 512 byte header is unused. */
-     buf += 404;
-     offsettab = buf;
+     bytestream2_skip_p(&pbc, 404);
  
      if (avctx->coder_type != FF_CODER_TYPE_RAW) {
+         PutByteContext taboff_pcb, tablen_pcb;
          /* Skip RLE offset table. */
-         buf += tablesize;
-         lengthtab = buf;
+         bytestream2_init_writer(&taboff_pcb, pbc.buffer, tablesize);
+         bytestream2_skip_p(&pbc, tablesize);
  
          /* Skip RLE length table. */
-         buf += tablesize;
+         bytestream2_init_writer(&tablen_pcb, pbc.buffer, tablesize);
+         bytestream2_skip_p(&pbc, tablesize);
  
          /* Make an intermediate consecutive buffer. */
          if (!(encode_buf = av_malloc(width)))