[FFmpeg-cvslog] avcodec/mqcenc: Add ff_mqc_flush_to()
Michael Niedermayer
git at videolan.org
Wed Jun 17 20:50:57 CEST 2015
ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Wed Jun 17 20:11:43 2015 +0200| [e6190045b3a119cc27efe9fbd91eb7881fb6f823] | committer: Michael Niedermayer
avcodec/mqcenc: Add ff_mqc_flush_to()
This is needed to separate the end padding from the bitstream, allowing
to end it multiple times without disturbing it.
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e6190045b3a119cc27efe9fbd91eb7881fb6f823
---
libavcodec/mqc.h | 1 +
libavcodec/mqcenc.c | 21 +++++++++++++++++++++
2 files changed, 22 insertions(+)
diff --git a/libavcodec/mqc.h b/libavcodec/mqc.h
index e4123c2..39104b1 100644
--- a/libavcodec/mqc.h
+++ b/libavcodec/mqc.h
@@ -59,6 +59,7 @@ int ff_mqc_length(MqcState *mqc);
/** flush the encoder [returns number of bytes encoded] */
int ff_mqc_flush(MqcState *mqc);
+int ff_mqc_flush_to(MqcState *mqc, uint8_t *dst, int *dst_len);
/* decoder */
diff --git a/libavcodec/mqcenc.c b/libavcodec/mqcenc.c
index 97d352b..b827527 100644
--- a/libavcodec/mqcenc.c
+++ b/libavcodec/mqcenc.c
@@ -25,6 +25,7 @@
* @author Kamil Nowosad
*/
+#include "libavutil/avassert.h"
#include "mqc.h"
static void byteout(MqcState *mqc)
@@ -117,3 +118,23 @@ int ff_mqc_flush(MqcState *mqc)
mqc->bp++;
return mqc->bp - mqc->bpstart;
}
+
+int ff_mqc_flush_to(MqcState *mqc, uint8_t *dst, int *dst_len)
+{
+ int len;
+ MqcState mqc2 = *mqc;
+ mqc2.bpstart=
+ mqc2.bp = dst;
+ *mqc2.bp = *mqc->bp;
+ ff_mqc_flush(&mqc2);
+ *dst_len = mqc2.bp - dst;
+ if (mqc->bp < mqc->bpstart) {
+ av_assert1(mqc->bpstart - mqc->bp == 1);
+ av_assert1(*dst_len > 0);
+ av_assert1(mqc->bp[0] == 0 && dst[0] == 0);
+ (*dst_len) --;
+ memmove(dst, dst+1, *dst_len);
+ return mqc->bp - mqc->bpstart + 1 + *dst_len;
+ }
+ return mqc->bp - mqc->bpstart + *dst_len;
+}
More information about the ffmpeg-cvslog
mailing list