OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 24 matching lines...) Expand all Loading... |
35 typedef vpx_codec_stream_info_t vp8_stream_info_t; | 35 typedef vpx_codec_stream_info_t vp8_stream_info_t; |
36 | 36 |
37 /* Structures for handling memory allocations */ | 37 /* Structures for handling memory allocations */ |
38 typedef enum | 38 typedef enum |
39 { | 39 { |
40 VP8_SEG_ALG_PRIV = 256, | 40 VP8_SEG_ALG_PRIV = 256, |
41 VP8_SEG_MAX | 41 VP8_SEG_MAX |
42 } mem_seg_id_t; | 42 } mem_seg_id_t; |
43 #define NELEMENTS(x) ((int)(sizeof(x)/sizeof(x[0]))) | 43 #define NELEMENTS(x) ((int)(sizeof(x)/sizeof(x[0]))) |
44 | 44 |
45 static unsigned long vp8_priv_sz(const vpx_codec_dec_cfg_t *si, vpx_codec_flags_
t); | |
46 | |
47 struct vpx_codec_alg_priv | 45 struct vpx_codec_alg_priv |
48 { | 46 { |
49 vpx_codec_priv_t base; | 47 vpx_codec_priv_t base; |
50 vpx_codec_dec_cfg_t cfg; | 48 vpx_codec_dec_cfg_t cfg; |
51 vp8_stream_info_t si; | 49 vp8_stream_info_t si; |
52 int decoder_init; | 50 int decoder_init; |
53 int postproc_cfg_set; | 51 int postproc_cfg_set; |
54 vp8_postproc_cfg_t postproc_cfg; | 52 vp8_postproc_cfg_t postproc_cfg; |
55 #if CONFIG_POSTPROC_VISUALIZER | 53 #if CONFIG_POSTPROC_VISUALIZER |
56 unsigned int dbg_postproc_flag; | 54 unsigned int dbg_postproc_flag; |
57 int dbg_color_ref_frame_flag; | 55 int dbg_color_ref_frame_flag; |
58 int dbg_color_mb_modes_flag; | 56 int dbg_color_mb_modes_flag; |
59 int dbg_color_b_modes_flag; | 57 int dbg_color_b_modes_flag; |
60 int dbg_display_mv_flag; | 58 int dbg_display_mv_flag; |
61 #endif | 59 #endif |
62 vpx_decrypt_cb decrypt_cb; | 60 vpx_decrypt_cb decrypt_cb; |
63 void *decrypt_state; | 61 void *decrypt_state; |
64 vpx_image_t img; | 62 vpx_image_t img; |
65 int img_setup; | 63 int img_setup; |
66 struct frame_buffers yv12_frame_buffers; | 64 struct frame_buffers yv12_frame_buffers; |
67 void *user_priv; | 65 void *user_priv; |
68 FRAGMENT_DATA fragments; | 66 FRAGMENT_DATA fragments; |
69 }; | 67 }; |
70 | 68 |
71 static unsigned long vp8_priv_sz(const vpx_codec_dec_cfg_t *si, vpx_codec_flags_
t flags) | |
72 { | |
73 /* Although this declaration is constant, we can't use it in the requested | |
74 * segments list because we want to define the requested segments list | |
75 * before defining the private type (so that the number of memory maps is | |
76 * known) | |
77 */ | |
78 (void)si; | |
79 (void)flags; | |
80 return sizeof(vpx_codec_alg_priv_t); | |
81 } | |
82 | |
83 static void vp8_init_ctx(vpx_codec_ctx_t *ctx) | 69 static void vp8_init_ctx(vpx_codec_ctx_t *ctx) |
84 { | 70 { |
85 vpx_codec_alg_priv_t *priv = | 71 vpx_codec_alg_priv_t *priv = |
86 (vpx_codec_alg_priv_t *)vpx_calloc(1, sizeof(*priv)); | 72 (vpx_codec_alg_priv_t *)vpx_calloc(1, sizeof(*priv)); |
87 | 73 |
88 ctx->priv = (vpx_codec_priv_t *)priv; | 74 ctx->priv = (vpx_codec_priv_t *)priv; |
89 ctx->priv->init_flags = ctx->init_flags; | 75 ctx->priv->init_flags = ctx->init_flags; |
90 | 76 |
91 priv->si.sz = sizeof(priv->si); | 77 priv->si.sz = sizeof(priv->si); |
92 priv->decrypt_cb = NULL; | 78 priv->decrypt_cb = NULL; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 /* Parse uncompresssed part of key frame header. | 159 /* Parse uncompresssed part of key frame header. |
174 * 3 bytes:- including version, frame type and an offset | 160 * 3 bytes:- including version, frame type and an offset |
175 * 3 bytes:- sync code (0x9d, 0x01, 0x2a) | 161 * 3 bytes:- sync code (0x9d, 0x01, 0x2a) |
176 * 4 bytes:- including image width and height in the lowest 14 bits | 162 * 4 bytes:- including image width and height in the lowest 14 bits |
177 * of each 2-byte value. | 163 * of each 2-byte value. |
178 */ | 164 */ |
179 uint8_t clear_buffer[10]; | 165 uint8_t clear_buffer[10]; |
180 const uint8_t *clear = data; | 166 const uint8_t *clear = data; |
181 if (decrypt_cb) | 167 if (decrypt_cb) |
182 { | 168 { |
183 int n = MIN(sizeof(clear_buffer), data_sz); | 169 int n = VPXMIN(sizeof(clear_buffer), data_sz); |
184 decrypt_cb(decrypt_state, data, clear_buffer, n); | 170 decrypt_cb(decrypt_state, data, clear_buffer, n); |
185 clear = clear_buffer; | 171 clear = clear_buffer; |
186 } | 172 } |
187 si->is_kf = 0; | 173 si->is_kf = 0; |
188 | 174 |
189 if (data_sz >= 10 && !(clear[0] & 0x01)) /* I-Frame */ | 175 if (data_sz >= 10 && !(clear[0] & 0x01)) /* I-Frame */ |
190 { | 176 { |
191 si->is_kf = 1; | 177 si->is_kf = 1; |
192 | 178 |
193 /* vet via sync code */ | 179 /* vet via sync code */ |
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
824 { /* encoder functions */ | 810 { /* encoder functions */ |
825 0, | 811 0, |
826 NULL, | 812 NULL, |
827 NULL, | 813 NULL, |
828 NULL, | 814 NULL, |
829 NULL, | 815 NULL, |
830 NULL, | 816 NULL, |
831 NULL | 817 NULL |
832 } | 818 } |
833 }; | 819 }; |
OLD | NEW |