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 13 #include "./tools_common.h" 14 15 #ifdef __cplusplus 16 extern "C" { 17 #endif 18 19 struct VpxInputContext; 20 21 struct WebmInputContext { 22 void *reader; 23 void *segment; 24 uint8_t *buffer; 25 const void *cluster; 26 const void *block_entry; 27 const void *block; 28 int block_frame_index; 29 int video_track_index; 30 uint64_t timestamp_ns; 31 int is_key_frame; 32 int reached_eos; 33 }; 34 35 // Checks if the input is a WebM file. If so, initializes WebMInputContext so 36 // that webm_read_frame can be called to retrieve a video frame. 37 // Returns 1 on success and 0 on failure or input is not WebM file. 38 // TODO(vigneshv): Refactor this function into two smaller functions specific 39 // to their task. 40 int file_is_webm(struct WebmInputContext *webm_ctx, 41 struct VpxInputContext *vpx_ctx); 42 43 // Reads a WebM Video Frame. Memory for the buffer is created, owned and managed 44 // by this function. For the first call, |buffer| should be NULL and 45 // |*buffer_size| should be 0. Once all the frames are read and used, 46 // webm_free() should be called, otherwise there will be a leak. 47 // Parameters: 48 // webm_ctx - WebmInputContext object 49 // buffer - pointer where the frame data will be filled. 50 // buffer_size - pointer to buffer size. 51 // Return values: 52 // 0 - Success 53 // 1 - End of Stream 54 // -1 - Error 55 int webm_read_frame(struct WebmInputContext *webm_ctx, uint8_t **buffer, 56 size_t *buffer_size); 57 58 // Guesses the frame rate of the input file based on the container timestamps. 59 int webm_guess_framerate(struct WebmInputContext *webm_ctx, 60 struct VpxInputContext *vpx_ctx); 61 62 // Resets the WebMInputContext. 63 void webm_free(struct WebmInputContext *webm_ctx); 64 65 #ifdef __cplusplus 66 } // extern "C" 67 #endif 68 69 #endif // VPX_WEBMDEC_H_ 70