| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 #if CONFIG_POSTPROC_VISUALIZER | 53 #if CONFIG_POSTPROC_VISUALIZER |
| 54 unsigned int dbg_postproc_flag; | 54 unsigned int dbg_postproc_flag; |
| 55 int dbg_color_ref_frame_flag; | 55 int dbg_color_ref_frame_flag; |
| 56 int dbg_color_mb_modes_flag; | 56 int dbg_color_mb_modes_flag; |
| 57 int dbg_color_b_modes_flag; | 57 int dbg_color_b_modes_flag; |
| 58 int dbg_display_mv_flag; | 58 int dbg_display_mv_flag; |
| 59 #endif | 59 #endif |
| 60 vpx_decrypt_cb decrypt_cb; | 60 vpx_decrypt_cb decrypt_cb; |
| 61 void *decrypt_state; | 61 void *decrypt_state; |
| 62 vpx_image_t img; | 62 vpx_image_t img; |
| 63 int flushed; | |
| 64 int img_setup; | 63 int img_setup; |
| 65 struct frame_buffers yv12_frame_buffers; | 64 struct frame_buffers yv12_frame_buffers; |
| 66 void *user_priv; | 65 void *user_priv; |
| 67 FRAGMENT_DATA fragments; | 66 FRAGMENT_DATA fragments; |
| 68 }; | 67 }; |
| 69 | 68 |
| 70 static unsigned long vp8_priv_sz(const vpx_codec_dec_cfg_t *si, vpx_codec_flags_
t flags) | 69 static unsigned long vp8_priv_sz(const vpx_codec_dec_cfg_t *si, vpx_codec_flags_
t flags) |
| 71 { | 70 { |
| 72 /* Although this declaration is constant, we can't use it in the requested | 71 /* Although this declaration is constant, we can't use it in the requested |
| 73 * segments list because we want to define the requested segments list | 72 * segments list because we want to define the requested segments list |
| 74 * before defining the private type (so that the number of memory maps is | 73 * before defining the private type (so that the number of memory maps is |
| 75 * known) | 74 * known) |
| 76 */ | 75 */ |
| 77 (void)si; | 76 (void)si; |
| 77 (void)flags; |
| 78 return sizeof(vpx_codec_alg_priv_t); | 78 return sizeof(vpx_codec_alg_priv_t); |
| 79 } | 79 } |
| 80 | 80 |
| 81 static void vp8_init_ctx(vpx_codec_ctx_t *ctx) | 81 static void vp8_init_ctx(vpx_codec_ctx_t *ctx) |
| 82 { | 82 { |
| 83 vpx_codec_alg_priv_t *priv = | 83 vpx_codec_alg_priv_t *priv = |
| 84 (vpx_codec_alg_priv_t *)vpx_calloc(1, sizeof(*priv)); | 84 (vpx_codec_alg_priv_t *)vpx_calloc(1, sizeof(*priv)); |
| 85 | 85 |
| 86 ctx->priv = (vpx_codec_priv_t *)priv; | 86 ctx->priv = (vpx_codec_priv_t *)priv; |
| 87 ctx->priv->init_flags = ctx->init_flags; | 87 ctx->priv->init_flags = ctx->init_flags; |
| 88 | 88 |
| 89 priv->si.sz = sizeof(priv->si); | 89 priv->si.sz = sizeof(priv->si); |
| 90 priv->decrypt_cb = NULL; | 90 priv->decrypt_cb = NULL; |
| 91 priv->decrypt_state = NULL; | 91 priv->decrypt_state = NULL; |
| 92 priv->flushed = 0; | |
| 93 | 92 |
| 94 if (ctx->config.dec) | 93 if (ctx->config.dec) |
| 95 { | 94 { |
| 96 /* Update the reference to the config structure to an internal copy. */ | 95 /* Update the reference to the config structure to an internal copy. */ |
| 97 priv->cfg = *ctx->config.dec; | 96 priv->cfg = *ctx->config.dec; |
| 98 ctx->config.dec = &priv->cfg; | 97 ctx->config.dec = &priv->cfg; |
| 99 } | 98 } |
| 100 } | 99 } |
| 101 | 100 |
| 102 static vpx_codec_err_t vp8_init(vpx_codec_ctx_t *ctx, | 101 static vpx_codec_err_t vp8_init(vpx_codec_ctx_t *ctx, |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 clear = clear_buffer; | 181 clear = clear_buffer; |
| 183 } | 182 } |
| 184 si->is_kf = 0; | 183 si->is_kf = 0; |
| 185 | 184 |
| 186 if (data_sz >= 10 && !(clear[0] & 0x01)) /* I-Frame */ | 185 if (data_sz >= 10 && !(clear[0] & 0x01)) /* I-Frame */ |
| 187 { | 186 { |
| 188 si->is_kf = 1; | 187 si->is_kf = 1; |
| 189 | 188 |
| 190 /* vet via sync code */ | 189 /* vet via sync code */ |
| 191 if (clear[3] != 0x9d || clear[4] != 0x01 || clear[5] != 0x2a) | 190 if (clear[3] != 0x9d || clear[4] != 0x01 || clear[5] != 0x2a) |
| 192 res = VPX_CODEC_UNSUP_BITSTREAM; | 191 return VPX_CODEC_UNSUP_BITSTREAM; |
| 193 | 192 |
| 194 si->w = (clear[6] | (clear[7] << 8)) & 0x3fff; | 193 si->w = (clear[6] | (clear[7] << 8)) & 0x3fff; |
| 195 si->h = (clear[8] | (clear[9] << 8)) & 0x3fff; | 194 si->h = (clear[8] | (clear[9] << 8)) & 0x3fff; |
| 196 | 195 |
| 197 /*printf("w=%d, h=%d\n", si->w, si->h);*/ | 196 /*printf("w=%d, h=%d\n", si->w, si->h);*/ |
| 198 if (!(si->h | si->w)) | 197 if (!(si->h | si->w)) |
| 199 res = VPX_CODEC_UNSUP_BITSTREAM; | 198 res = VPX_CODEC_UNSUP_BITSTREAM; |
| 200 } | 199 } |
| 201 else | 200 else |
| 202 { | 201 { |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 ctx->fragments.count++; | 299 ctx->fragments.count++; |
| 301 if (ctx->fragments.count > (1 << EIGHT_PARTITION) + 1) | 300 if (ctx->fragments.count > (1 << EIGHT_PARTITION) + 1) |
| 302 { | 301 { |
| 303 ctx->fragments.count = 0; | 302 ctx->fragments.count = 0; |
| 304 *res = VPX_CODEC_INVALID_PARAM; | 303 *res = VPX_CODEC_INVALID_PARAM; |
| 305 return -1; | 304 return -1; |
| 306 } | 305 } |
| 307 return 0; | 306 return 0; |
| 308 } | 307 } |
| 309 | 308 |
| 309 if (!ctx->fragments.enabled && (data == NULL && data_sz == 0)) |
| 310 { |
| 311 return 0; |
| 312 } |
| 313 |
| 310 if (!ctx->fragments.enabled) | 314 if (!ctx->fragments.enabled) |
| 311 { | 315 { |
| 312 ctx->fragments.ptrs[0] = data; | 316 ctx->fragments.ptrs[0] = data; |
| 313 ctx->fragments.sizes[0] = data_sz; | 317 ctx->fragments.sizes[0] = data_sz; |
| 314 ctx->fragments.count = 1; | 318 ctx->fragments.count = 1; |
| 315 } | 319 } |
| 316 | 320 |
| 317 return 1; | 321 return 1; |
| 318 } | 322 } |
| 319 | 323 |
| 320 static vpx_codec_err_t vp8_decode(vpx_codec_alg_priv_t *ctx, | 324 static vpx_codec_err_t vp8_decode(vpx_codec_alg_priv_t *ctx, |
| 321 const uint8_t *data, | 325 const uint8_t *data, |
| 322 unsigned int data_sz, | 326 unsigned int data_sz, |
| 323 void *user_priv, | 327 void *user_priv, |
| 324 long deadline) | 328 long deadline) |
| 325 { | 329 { |
| 326 vpx_codec_err_t res = VPX_CODEC_OK; | 330 vpx_codec_err_t res = VPX_CODEC_OK; |
| 327 unsigned int resolution_change = 0; | 331 unsigned int resolution_change = 0; |
| 328 unsigned int w, h; | 332 unsigned int w, h; |
| 329 | 333 |
| 330 if (data == NULL && data_sz == 0) { | 334 if (!ctx->fragments.enabled && (data == NULL && data_sz == 0)) |
| 331 ctx->flushed = 1; | 335 { |
| 332 return VPX_CODEC_OK; | 336 return 0; |
| 333 } | 337 } |
| 334 | 338 |
| 335 /* Reset flushed when receiving a valid frame */ | |
| 336 ctx->flushed = 0; | |
| 337 | |
| 338 /* Update the input fragment data */ | 339 /* Update the input fragment data */ |
| 339 if(update_fragments(ctx, data, data_sz, &res) <= 0) | 340 if(update_fragments(ctx, data, data_sz, &res) <= 0) |
| 340 return res; | 341 return res; |
| 341 | 342 |
| 342 /* Determine the stream parameters. Note that we rely on peek_si to | 343 /* Determine the stream parameters. Note that we rely on peek_si to |
| 343 * validate that we have a buffer that does not wrap around the top | 344 * validate that we have a buffer that does not wrap around the top |
| 344 * of the heap. | 345 * of the heap. |
| 345 */ | 346 */ |
| 346 w = ctx->si.w; | 347 w = ctx->si.w; |
| 347 h = ctx->si.h; | 348 h = ctx->si.h; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 * decrypt config between frames. | 395 * decrypt config between frames. |
| 395 */ | 396 */ |
| 396 if (ctx->decoder_init) { | 397 if (ctx->decoder_init) { |
| 397 ctx->yv12_frame_buffers.pbi[0]->decrypt_cb = ctx->decrypt_cb; | 398 ctx->yv12_frame_buffers.pbi[0]->decrypt_cb = ctx->decrypt_cb; |
| 398 ctx->yv12_frame_buffers.pbi[0]->decrypt_state = ctx->decrypt_state; | 399 ctx->yv12_frame_buffers.pbi[0]->decrypt_state = ctx->decrypt_state; |
| 399 } | 400 } |
| 400 | 401 |
| 401 if (!res) | 402 if (!res) |
| 402 { | 403 { |
| 403 VP8D_COMP *pbi = ctx->yv12_frame_buffers.pbi[0]; | 404 VP8D_COMP *pbi = ctx->yv12_frame_buffers.pbi[0]; |
| 404 if(resolution_change) | 405 if (resolution_change) |
| 405 { | 406 { |
| 406 VP8_COMMON *const pc = & pbi->common; | 407 VP8_COMMON *const pc = & pbi->common; |
| 407 MACROBLOCKD *const xd = & pbi->mb; | 408 MACROBLOCKD *const xd = & pbi->mb; |
| 408 #if CONFIG_MULTITHREAD | 409 #if CONFIG_MULTITHREAD |
| 409 int i; | 410 int i; |
| 410 #endif | 411 #endif |
| 411 pc->Width = ctx->si.w; | 412 pc->Width = ctx->si.w; |
| 412 pc->Height = ctx->si.h; | 413 pc->Height = ctx->si.h; |
| 413 { | 414 { |
| 414 int prev_mb_rows = pc->mb_rows; | 415 int prev_mb_rows = pc->mb_rows; |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 if (data) | 641 if (data) |
| 641 { | 642 { |
| 642 ctx->postproc_cfg_set = 1; | 643 ctx->postproc_cfg_set = 1; |
| 643 ctx->postproc_cfg = *((vp8_postproc_cfg_t *)data); | 644 ctx->postproc_cfg = *((vp8_postproc_cfg_t *)data); |
| 644 return VPX_CODEC_OK; | 645 return VPX_CODEC_OK; |
| 645 } | 646 } |
| 646 else | 647 else |
| 647 return VPX_CODEC_INVALID_PARAM; | 648 return VPX_CODEC_INVALID_PARAM; |
| 648 | 649 |
| 649 #else | 650 #else |
| 651 (void)ctx; |
| 652 (void)args; |
| 650 return VPX_CODEC_INCAPABLE; | 653 return VPX_CODEC_INCAPABLE; |
| 651 #endif | 654 #endif |
| 652 } | 655 } |
| 653 | 656 |
| 654 | 657 |
| 655 static vpx_codec_err_t vp8_set_dbg_color_ref_frame(vpx_codec_alg_priv_t *ctx, | 658 static vpx_codec_err_t vp8_set_dbg_color_ref_frame(vpx_codec_alg_priv_t *ctx, |
| 656 va_list args) { | 659 va_list args) { |
| 657 #if CONFIG_POSTPROC_VISUALIZER && CONFIG_POSTPROC | 660 #if CONFIG_POSTPROC_VISUALIZER && CONFIG_POSTPROC |
| 658 ctx->dbg_color_ref_frame_flag = va_arg(args, int); | 661 ctx->dbg_color_ref_frame_flag = va_arg(args, int); |
| 659 return VPX_CODEC_OK; | 662 return VPX_CODEC_OK; |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 817 { /* encoder functions */ | 820 { /* encoder functions */ |
| 818 0, | 821 0, |
| 819 NULL, | 822 NULL, |
| 820 NULL, | 823 NULL, |
| 821 NULL, | 824 NULL, |
| 822 NULL, | 825 NULL, |
| 823 NULL, | 826 NULL, |
| 824 NULL | 827 NULL |
| 825 } | 828 } |
| 826 }; | 829 }; |
| OLD | NEW |