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.

134 lines
3.8KB

  1. /*
  2. * Copyright (c) 2008 BBC, Anuradha Suraparaju <asuraparaju at gmail dot com >
  3. *
  4. * This file is part of Libav.
  5. *
  6. * Libav is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * Libav is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with Libav; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. /**
  21. * @file
  22. * data structures common to libschroedinger decoder and encoder
  23. */
  24. #ifndef AVCODEC_LIBSCHROEDINGER_H
  25. #define AVCODEC_LIBSCHROEDINGER_H
  26. #include <schroedinger/schrobitstream.h>
  27. #include <schroedinger/schroframe.h>
  28. #include "avcodec.h"
  29. typedef struct SchroVideoFormatInfo {
  30. uint16_t width;
  31. uint16_t height;
  32. uint16_t frame_rate_num;
  33. uint16_t frame_rate_denom;
  34. } SchroVideoFormatInfo;
  35. /**
  36. * contains a single encoded frame returned from Dirac or Schroedinger
  37. */
  38. typedef struct FFSchroEncodedFrame {
  39. /** encoded frame data */
  40. uint8_t *p_encbuf;
  41. /** encoded frame size */
  42. uint32_t size;
  43. /** encoded frame number. Will be used as pts */
  44. uint32_t frame_num;
  45. /** key frame flag. 1 : is key frame , 0 : in not key frame */
  46. uint16_t key_frame;
  47. } FFSchroEncodedFrame;
  48. /**
  49. * queue element
  50. */
  51. typedef struct FFSchroQueueElement {
  52. /** Data to be stored in queue*/
  53. void *data;
  54. /** Pointer to next element queue */
  55. struct FFSchroQueueElement *next;
  56. } FFSchroQueueElement;
  57. /**
  58. * A simple queue implementation used in libschroedinger
  59. */
  60. typedef struct FFSchroQueue {
  61. /** Pointer to head of queue */
  62. FFSchroQueueElement *p_head;
  63. /** Pointer to tail of queue */
  64. FFSchroQueueElement *p_tail;
  65. /** Queue size*/
  66. int size;
  67. } FFSchroQueue;
  68. /**
  69. * Initialise the queue
  70. */
  71. void ff_schro_queue_init(FFSchroQueue *queue);
  72. /**
  73. * Add an element to the end of the queue
  74. */
  75. int ff_schro_queue_push_back(FFSchroQueue *queue, void *p_data);
  76. /**
  77. * Return the first element in the queue
  78. */
  79. void *ff_schro_queue_pop(FFSchroQueue *queue);
  80. /**
  81. * Free the queue resources. free_func is a function supplied by the caller to
  82. * free any resources allocated by the caller. The data field of the queue
  83. * element is passed to it.
  84. */
  85. void ff_schro_queue_free(FFSchroQueue *queue, void (*free_func)(void *));
  86. static const struct {
  87. enum AVPixelFormat ff_pix_fmt;
  88. SchroChromaFormat schro_pix_fmt;
  89. SchroFrameFormat schro_frame_fmt;
  90. } schro_pixel_format_map[] = {
  91. { AV_PIX_FMT_YUV420P, SCHRO_CHROMA_420, SCHRO_FRAME_FORMAT_U8_420 },
  92. { AV_PIX_FMT_YUV422P, SCHRO_CHROMA_422, SCHRO_FRAME_FORMAT_U8_422 },
  93. { AV_PIX_FMT_YUV444P, SCHRO_CHROMA_444, SCHRO_FRAME_FORMAT_U8_444 },
  94. };
  95. /**
  96. * Returns the video format preset matching the input video dimensions and
  97. * time base.
  98. */
  99. SchroVideoFormatEnum ff_get_schro_video_format_preset (AVCodecContext *avctx);
  100. /**
  101. * Sets the Schroedinger frame format corresponding to the Schro chroma format
  102. * passed. Returns 0 on success, -1 on failure.
  103. */
  104. int ff_get_schro_frame_format(SchroChromaFormat schro_chroma_fmt,
  105. SchroFrameFormat *schro_frame_fmt);
  106. /**
  107. * Create a Schro frame based on the dimensions and frame format
  108. * passed. Returns a pointer to a frame on success, NULL on failure.
  109. */
  110. SchroFrame *ff_create_schro_frame(AVCodecContext *avctx,
  111. SchroFrameFormat schro_frame_fmt);
  112. #endif /* AVCODEC_LIBSCHROEDINGER_H */