• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2016, Alliance for Open Media. All rights reserved
3  *
4  * This source code is subject to the terms of the BSD 2 Clause License and
5  * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6  * was not distributed with this source code in the LICENSE file, you can
7  * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8  * Media Patent License 1.0 was not distributed with this source code in the
9  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10  */
11 #ifndef AOM_COMMON_WEBMDEC_H_
12 #define AOM_COMMON_WEBMDEC_H_
13 
14 #include "common/tools_common.h"
15 
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19 
20 struct AvxInputContext;
21 
22 struct WebmInputContext {
23   void *reader;
24   void *segment;
25   uint8_t *buffer;
26   const void *cluster;
27   const void *block_entry;
28   const void *block;
29   int block_frame_index;
30   int video_track_index;
31   uint64_t timestamp_ns;
32   int is_key_frame;
33   int reached_eos;
34 };
35 
36 // Checks if the input is a WebM file. If so, initializes WebMInputContext so
37 // that webm_read_frame can be called to retrieve a video frame.
38 // Returns 1 on success and 0 on failure or input is not WebM file.
39 // TODO(vigneshv): Refactor this function into two smaller functions specific
40 // to their task.
41 int file_is_webm(struct WebmInputContext *webm_ctx,
42                  struct AvxInputContext *aom_ctx);
43 
44 // Reads a WebM Video Frame. Memory for the buffer is created, owned and managed
45 // by this function. For the first call, |buffer| should be NULL and
46 // |*buffer_size| should be 0. Once all the frames are read and used,
47 // webm_free() should be called, otherwise there will be a leak.
48 // Parameters:
49 //      webm_ctx - WebmInputContext object
50 //      buffer - pointer where the frame data will be filled.
51 //      bytes_read - pointer to bytes read.
52 //      buffer_size - pointer to buffer size.
53 // Return values:
54 //      0 - Success
55 //      1 - End of Stream
56 //     -1 - Error
57 int webm_read_frame(struct WebmInputContext *webm_ctx, uint8_t **buffer,
58                     size_t *bytes_read, size_t *buffer_size);
59 
60 // Guesses the frame rate of the input file based on the container timestamps.
61 int webm_guess_framerate(struct WebmInputContext *webm_ctx,
62                          struct AvxInputContext *aom_ctx);
63 
64 // Resets the WebMInputContext.
65 void webm_free(struct WebmInputContext *webm_ctx);
66 
67 #ifdef __cplusplus
68 }  // extern "C"
69 #endif
70 
71 #endif  // AOM_COMMON_WEBMDEC_H_
72