summaryrefslogtreecommitdiff
path: root/libavcodec/cbs_internal.h
diff options
context:
space:
mode:
authorMark Thompson <sw@jkqxz.net>2017-05-04 23:01:51 +0100
committerMark Thompson <sw@jkqxz.net>2017-10-17 20:56:29 +0100
commit6734eef6b8b464139fdc140ec9bc9e8d74173869 (patch)
tree24de1429ab9114edf7d332248fb163a17f809a38 /libavcodec/cbs_internal.h
parentb1374e925c1cf3af5c8482119f3f2630d66213de (diff)
lavc: Add coded bitstream read/write API
(cherry picked from commit 18f1706f331bf5dd565774eae680508c8d3a97ad) (cherry picked from commit 44cde38c8acbef7d5250e6d1b52b1020871e093b)
Diffstat (limited to 'libavcodec/cbs_internal.h')
-rw-r--r--libavcodec/cbs_internal.h86
1 files changed, 86 insertions, 0 deletions
diff --git a/libavcodec/cbs_internal.h b/libavcodec/cbs_internal.h
new file mode 100644
index 0000000000..f6a42beea3
--- /dev/null
+++ b/libavcodec/cbs_internal.h
@@ -0,0 +1,86 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_CBS_INTERNAL_H
+#define AVCODEC_CBS_INTERNAL_H
+
+#include "avcodec.h"
+#include "cbs.h"
+#include "get_bits.h"
+#include "put_bits.h"
+
+
+typedef struct CodedBitstreamType {
+ enum AVCodecID codec_id;
+
+ size_t priv_data_size;
+
+ // Split frag->data into coded bitstream units, creating the
+ // frag->units array. Fill data but not content on each unit.
+ // header is set if the fragment came from a header block, which
+ // may require different parsing for some codecs (e.g. the AVCC
+ // header in H.264).
+ int (*split_fragment)(CodedBitstreamContext *ctx,
+ CodedBitstreamFragment *frag,
+ int header);
+
+ // Read the unit->data bitstream and decompose it, creating
+ // unit->content.
+ int (*read_unit)(CodedBitstreamContext *ctx,
+ CodedBitstreamUnit *unit);
+
+ // Write the unit->data bitstream from unit->content.
+ int (*write_unit)(CodedBitstreamContext *ctx,
+ CodedBitstreamUnit *unit);
+
+ // Read the data from all of frag->units and assemble it into
+ // a bitstream for the whole fragment.
+ int (*assemble_fragment)(CodedBitstreamContext *ctx,
+ CodedBitstreamFragment *frag);
+
+ // Free the content and data of a single unit.
+ void (*free_unit)(CodedBitstreamUnit *unit);
+
+ // Free the codec internal state.
+ void (*close)(CodedBitstreamContext *ctx);
+} CodedBitstreamType;
+
+
+// Helper functions for trace output.
+
+void ff_cbs_trace_header(CodedBitstreamContext *ctx,
+ const char *name);
+
+void ff_cbs_trace_syntax_element(CodedBitstreamContext *ctx,
+ int position, const char *name,
+ const char *bitstring, int64_t value);
+
+
+// Helper functions for read/write of common bitstream elements, including
+// generation of trace output.
+
+int ff_cbs_read_unsigned(CodedBitstreamContext *ctx, GetBitContext *gbc,
+ int width, const char *name, uint32_t *write_to,
+ uint32_t range_min, uint32_t range_max);
+
+int ff_cbs_write_unsigned(CodedBitstreamContext *ctx, PutBitContext *pbc,
+ int width, const char *name, uint32_t value,
+ uint32_t range_min, uint32_t range_max);
+
+
+#endif /* AVCODEC_CBS_INTERNAL_H */