webmdec.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * Copyright (c) 2013 The WebM project authors. All Rights Reserved.
  3. *
  4. * Use of this source code is governed by a BSD-style license
  5. * that can be found in the LICENSE file in the root of the source
  6. * tree. An additional intellectual property rights grant can be found
  7. * in the file PATENTS. All contributing project authors may
  8. * be found in the AUTHORS file in the root of the source tree.
  9. */
  10. #ifndef VPX_WEBMDEC_H_
  11. #define VPX_WEBMDEC_H_
  12. #include "./tools_common.h"
  13. #ifdef __cplusplus
  14. extern "C" {
  15. #endif
  16. struct VpxInputContext;
  17. struct WebmInputContext {
  18. void *reader;
  19. void *segment;
  20. uint8_t *buffer;
  21. const void *cluster;
  22. const void *block_entry;
  23. const void *block;
  24. int block_frame_index;
  25. int video_track_index;
  26. uint64_t timestamp_ns;
  27. int is_key_frame;
  28. int reached_eos;
  29. };
  30. // Checks if the input is a WebM file. If so, initializes WebMInputContext so
  31. // that webm_read_frame can be called to retrieve a video frame.
  32. // Returns 1 on success and 0 on failure or input is not WebM file.
  33. // TODO(vigneshv): Refactor this function into two smaller functions specific
  34. // to their task.
  35. int file_is_webm(struct WebmInputContext *webm_ctx,
  36. struct VpxInputContext *vpx_ctx);
  37. // Reads a WebM Video Frame. Memory for the buffer is created, owned and managed
  38. // by this function. For the first call, |buffer| should be NULL and
  39. // |*buffer_size| should be 0. Once all the frames are read and used,
  40. // webm_free() should be called, otherwise there will be a leak.
  41. // Parameters:
  42. // webm_ctx - WebmInputContext object
  43. // buffer - pointer where the frame data will be filled.
  44. // buffer_size - pointer to buffer size.
  45. // Return values:
  46. // 0 - Success
  47. // 1 - End of Stream
  48. // -1 - Error
  49. int webm_read_frame(struct WebmInputContext *webm_ctx, uint8_t **buffer,
  50. size_t *buffer_size);
  51. // Guesses the frame rate of the input file based on the container timestamps.
  52. int webm_guess_framerate(struct WebmInputContext *webm_ctx,
  53. struct VpxInputContext *vpx_ctx);
  54. // Resets the WebMInputContext.
  55. void webm_free(struct WebmInputContext *webm_ctx);
  56. #ifdef __cplusplus
  57. } // extern "C"
  58. #endif
  59. #endif // VPX_WEBMDEC_H_