You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

88 lines
3.0KB

  1. /*
  2. * This file is part of Libav.
  3. *
  4. * Libav is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2.1 of the License, or (at your option) any later version.
  8. *
  9. * Libav is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with Libav; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #ifndef AVCODEC_CBS_INTERNAL_H
  19. #define AVCODEC_CBS_INTERNAL_H
  20. #include "avcodec.h"
  21. #include "bitstream.h"
  22. #include "cbs.h"
  23. #include "put_bits.h"
  24. typedef struct CodedBitstreamType {
  25. enum AVCodecID codec_id;
  26. size_t priv_data_size;
  27. // Split frag->data into coded bitstream units, creating the
  28. // frag->units array. Fill data but not content on each unit.
  29. int (*split_fragment)(CodedBitstreamContext *ctx,
  30. CodedBitstreamFragment *frag,
  31. int header);
  32. // Read the unit->data bitstream and decompose it, creating
  33. // unit->content.
  34. int (*read_unit)(CodedBitstreamContext *ctx,
  35. CodedBitstreamUnit *unit);
  36. // Write the unit->data bitstream from unit->content.
  37. int (*write_unit)(CodedBitstreamContext *ctx,
  38. CodedBitstreamUnit *unit);
  39. // Read the data from all of frag->units and assemble it into
  40. // a bitstream for the whole fragment.
  41. int (*assemble_fragment)(CodedBitstreamContext *ctx,
  42. CodedBitstreamFragment *frag);
  43. // Free the content and data of a single unit.
  44. void (*free_unit)(CodedBitstreamUnit *unit);
  45. // Free the codec internal state.
  46. void (*close)(CodedBitstreamContext *ctx);
  47. } CodedBitstreamType;
  48. // Helper functions for trace output.
  49. void ff_cbs_trace_header(CodedBitstreamContext *ctx,
  50. const char *name);
  51. void ff_cbs_trace_syntax_element(CodedBitstreamContext *ctx,
  52. int position, const char *name,
  53. const char *bitstring, int64_t value);
  54. // Helper functions for read/write of common bitstream elements, including
  55. // generation of trace output.
  56. int ff_cbs_read_unsigned(CodedBitstreamContext *ctx, BitstreamContext *bc,
  57. int width, const char *name, uint32_t *write_to,
  58. uint32_t range_min, uint32_t range_max);
  59. int ff_cbs_write_unsigned(CodedBitstreamContext *ctx, PutBitContext *pbc,
  60. int width, const char *name, uint32_t value,
  61. uint32_t range_min, uint32_t range_max);
  62. extern const CodedBitstreamType ff_cbs_type_h264;
  63. extern const CodedBitstreamType ff_cbs_type_h265;
  64. #endif /* AVCODEC_CBS_INTERNAL_H */