aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2019-11-19 17:12:28 +0100
committerMark Thompson <sw@jkqxz.net>2020-02-09 22:36:50 +0000
commit5ad1c1a18a38883c5811153d81ac149391429a4d (patch)
tree1fddd6cefe36076fac94a19d5bee75feb02dd9a5
parentce920f47930d2a1df6628f026a926425f534e8d2 (diff)
downloadffmpeg-5ad1c1a18a38883c5811153d81ac149391429a4d.tar.gz
avcodec/cbs_jpeg: Use memcpy when writing pictures
This is possible because the size of a scan header is always a multiple of a byte. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
-rw-r--r--libavcodec/cbs_jpeg.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/libavcodec/cbs_jpeg.c b/libavcodec/cbs_jpeg.c
index b52e5c5823..6bbce5f89b 100644
--- a/libavcodec/cbs_jpeg.c
+++ b/libavcodec/cbs_jpeg.c
@@ -327,7 +327,7 @@ static int cbs_jpeg_write_scan(CodedBitstreamContext *ctx,
PutBitContext *pbc)
{
JPEGRawScan *scan = unit->content;
- int i, err;
+ int err;
err = cbs_jpeg_write_scan_header(ctx, pbc, &scan->header);
if (err < 0)
@@ -337,8 +337,12 @@ static int cbs_jpeg_write_scan(CodedBitstreamContext *ctx,
if (scan->data_size * 8 > put_bits_left(pbc))
return AVERROR(ENOSPC);
- for (i = 0; i < scan->data_size; i++)
- put_bits(pbc, 8, scan->data[i]);
+ av_assert0(put_bits_count(pbc) % 8 == 0);
+
+ flush_put_bits(pbc);
+
+ memcpy(put_bits_ptr(pbc), scan->data, scan->data_size);
+ skip_put_bytes(pbc, scan->data_size);
}
return 0;