webmdec.h 2.28 KB
Newer Older
1
/*
2
 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
3
 *
4 5 6 7 8 9
 * This source code is subject to the terms of the BSD 2 Clause License and
 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
 * was not distributed with this source code in the LICENSE file, you can
 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
 * Media Patent License 1.0 was not distributed with this source code in the
 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10 11 12 13 14 15
 */
#ifndef WEBMDEC_H_
#define WEBMDEC_H_

#include "./tools_common.h"

16 17 18 19
#ifdef __cplusplus
extern "C" {
#endif

20
struct AvxInputContext;
21 22

struct WebmInputContext {
23 24 25 26 27 28 29 30 31
  void *reader;
  void *segment;
  uint8_t *buffer;
  const void *cluster;
  const void *block_entry;
  const void *block;
  int block_frame_index;
  int video_track_index;
  uint64_t timestamp_ns;
32
  int is_key_frame;
33
  int reached_eos;
34 35
};

36 37 38 39 40
// Checks if the input is a WebM file. If so, initializes WebMInputContext so
// that webm_read_frame can be called to retrieve a video frame.
// Returns 1 on success and 0 on failure or input is not WebM file.
// TODO(vigneshv): Refactor this function into two smaller functions specific
// to their task.
41
int file_is_webm(struct WebmInputContext *webm_ctx,
42
                 struct AvxInputContext *aom_ctx);
43

44 45
// Reads a WebM Video Frame. Memory for the buffer is created, owned and managed
// 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 48 49 50
// webm_free() should be called, otherwise there will be a leak.
// Parameters:
//      webm_ctx - WebmInputContext object
//      buffer - pointer where the frame data will be filled.
51
//      buffer_size - pointer to buffer size.
52 53 54 55
// Return values:
//      0 - Success
//      1 - End of Stream
//     -1 - Error
56
int webm_read_frame(struct WebmInputContext *webm_ctx, uint8_t **buffer,
57 58
                    size_t *buffer_size);

59
// Guesses the frame rate of the input file based on the container timestamps.
60
int webm_guess_framerate(struct WebmInputContext *webm_ctx,
61
                         struct AvxInputContext *aom_ctx);
62

63
// Resets the WebMInputContext.
64 65
void webm_free(struct WebmInputContext *webm_ctx);

66 67 68 69
#ifdef __cplusplus
}  // extern "C"
#endif

70
#endif  // WEBMDEC_H_