shithub: libvpx

Download patch

ref: 0eac753dc059ba5938939968f8728075e35b5815
parent: 9c9fdf30e6ba7944a5fe7455d29312b49e777851
author: Dmitry Kovalev <[email protected]>
date: Mon Jan 13 06:57:55 EST 2014

Removing VpxInputContext dependency from {ivf, raw}_read_frame().

File type check inside ivf_read_frame() is not necessary (it is done
before this function get called).

Change-Id: Iede8feb358d25878b340473d85c3b01d701fc624

--- a/ivfdec.c
+++ b/ivfdec.c
@@ -65,16 +65,10 @@
   return is_ivf;
 }
 
-int ivf_read_frame(struct VpxInputContext *input_ctx,
-                   uint8_t **buffer,
-                   size_t *bytes_read,
-                   size_t *buffer_size) {
+int ivf_read_frame(FILE *infile, uint8_t **buffer,
+                   size_t *bytes_read, size_t *buffer_size) {
   char raw_header[IVF_FRAME_HDR_SZ] = {0};
   size_t frame_size = 0;
-  FILE *infile = input_ctx->file;
-
-  if (input_ctx->file_type != FILE_TYPE_IVF)
-    return 0;
 
   if (fread(raw_header, IVF_FRAME_HDR_SZ, 1, infile) != 1) {
     if (!feof(infile))
--- a/ivfdec.h
+++ b/ivfdec.h
@@ -18,10 +18,8 @@
 
 int file_is_ivf(struct VpxInputContext *input);
 
-int ivf_read_frame(struct VpxInputContext *input,
-                   uint8_t **buffer,
-                   size_t *bytes_read,
-                   size_t *buffer_size);
+int ivf_read_frame(FILE *infile, uint8_t **buffer,
+                   size_t *bytes_read, size_t *buffer_size);
 
 #ifdef __cplusplus
 }  /* extern "C" */
--- a/vpxdec.c
+++ b/vpxdec.c
@@ -167,11 +167,10 @@
   exit(EXIT_FAILURE);
 }
 
-static int raw_read_frame(struct VpxInputContext *input_ctx, uint8_t **buffer,
+static int raw_read_frame(FILE *infile, uint8_t **buffer,
                           size_t *bytes_read, size_t *buffer_size) {
   char raw_hdr[RAW_FRAME_HDR_SZ];
   size_t frame_size = 0;
-  FILE *infile = input_ctx->file;
 
   if (fread(raw_hdr, RAW_FRAME_HDR_SZ, 1, infile) != 1) {
     if (!feof(infile))
@@ -221,10 +220,10 @@
       return webm_read_frame(input->webm_ctx,
                              buf, bytes_in_buffer, buffer_size);
     case FILE_TYPE_RAW:
-      return raw_read_frame(input->vpx_input_ctx,
+      return raw_read_frame(input->vpx_input_ctx->file,
                             buf, bytes_in_buffer, buffer_size);
     case FILE_TYPE_IVF:
-      return ivf_read_frame(input->vpx_input_ctx,
+      return ivf_read_frame(input->vpx_input_ctx->file,
                             buf, bytes_in_buffer, buffer_size);
     default:
       return 1;