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; |
63 int img_setup; | 64 int img_setup; |
64 struct frame_buffers yv12_frame_buffers; | 65 struct frame_buffers yv12_frame_buffers; |
65 void *user_priv; | 66 void *user_priv; |
66 FRAGMENT_DATA fragments; | 67 FRAGMENT_DATA fragments; |
67 }; | 68 }; |
68 | 69 |
69 static unsigned long vp8_priv_sz(const vpx_codec_dec_cfg_t *si, vpx_codec_flags_
t flags) | 70 static unsigned long vp8_priv_sz(const vpx_codec_dec_cfg_t *si, vpx_codec_flags_
t flags) |
70 { | 71 { |
71 /* Although this declaration is constant, we can't use it in the requested | 72 /* Although this declaration is constant, we can't use it in the requested |
72 * segments list because we want to define the requested segments list | 73 * segments list because we want to define the requested segments list |
73 * before defining the private type (so that the number of memory maps is | 74 * before defining the private type (so that the number of memory maps is |
74 * known) | 75 * known) |
75 */ | 76 */ |
76 (void)si; | 77 (void)si; |
77 return sizeof(vpx_codec_alg_priv_t); | 78 return sizeof(vpx_codec_alg_priv_t); |
78 } | 79 } |
79 | 80 |
80 static void vp8_init_ctx(vpx_codec_ctx_t *ctx) | 81 static void vp8_init_ctx(vpx_codec_ctx_t *ctx) |
81 { | 82 { |
82 ctx->priv = | 83 ctx->priv = |
83 (vpx_codec_priv_t *)vpx_memalign(8, sizeof(vpx_codec_alg_priv_t)); | 84 (vpx_codec_priv_t *)vpx_memalign(8, sizeof(vpx_codec_alg_priv_t)); |
84 vpx_memset(ctx->priv, 0, sizeof(vpx_codec_alg_priv_t)); | 85 vpx_memset(ctx->priv, 0, sizeof(vpx_codec_alg_priv_t)); |
85 ctx->priv->sz = sizeof(*ctx->priv); | 86 ctx->priv->sz = sizeof(*ctx->priv); |
86 ctx->priv->iface = ctx->iface; | 87 ctx->priv->iface = ctx->iface; |
87 ctx->priv->alg_priv = (vpx_codec_alg_priv_t *)ctx->priv; | 88 ctx->priv->alg_priv = (vpx_codec_alg_priv_t *)ctx->priv; |
88 ctx->priv->alg_priv->si.sz = sizeof(ctx->priv->alg_priv->si); | 89 ctx->priv->alg_priv->si.sz = sizeof(ctx->priv->alg_priv->si); |
89 ctx->priv->alg_priv->decrypt_cb = NULL; | 90 ctx->priv->alg_priv->decrypt_cb = NULL; |
90 ctx->priv->alg_priv->decrypt_state = NULL; | 91 ctx->priv->alg_priv->decrypt_state = NULL; |
| 92 ctx->priv->alg_priv->flushed = 0; |
91 ctx->priv->init_flags = ctx->init_flags; | 93 ctx->priv->init_flags = ctx->init_flags; |
92 | 94 |
93 if (ctx->config.dec) | 95 if (ctx->config.dec) |
94 { | 96 { |
95 /* Update the reference to the config structure to an internal copy. */ | 97 /* Update the reference to the config structure to an internal copy. */ |
96 ctx->priv->alg_priv->cfg = *ctx->config.dec; | 98 ctx->priv->alg_priv->cfg = *ctx->config.dec; |
97 ctx->config.dec = &ctx->priv->alg_priv->cfg; | 99 ctx->config.dec = &ctx->priv->alg_priv->cfg; |
98 } | 100 } |
99 } | 101 } |
100 | 102 |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 static vpx_codec_err_t vp8_decode(vpx_codec_alg_priv_t *ctx, | 323 static vpx_codec_err_t vp8_decode(vpx_codec_alg_priv_t *ctx, |
322 const uint8_t *data, | 324 const uint8_t *data, |
323 unsigned int data_sz, | 325 unsigned int data_sz, |
324 void *user_priv, | 326 void *user_priv, |
325 long deadline) | 327 long deadline) |
326 { | 328 { |
327 vpx_codec_err_t res = VPX_CODEC_OK; | 329 vpx_codec_err_t res = VPX_CODEC_OK; |
328 unsigned int resolution_change = 0; | 330 unsigned int resolution_change = 0; |
329 unsigned int w, h; | 331 unsigned int w, h; |
330 | 332 |
| 333 if (data == NULL && data_sz == 0) { |
| 334 ctx->flushed = 1; |
| 335 return VPX_CODEC_OK; |
| 336 } |
| 337 |
| 338 /* Reset flushed when receiving a valid frame */ |
| 339 ctx->flushed = 0; |
331 | 340 |
332 /* Update the input fragment data */ | 341 /* Update the input fragment data */ |
333 if(update_fragments(ctx, data, data_sz, &res) <= 0) | 342 if(update_fragments(ctx, data, data_sz, &res) <= 0) |
334 return res; | 343 return res; |
335 | 344 |
336 /* Determine the stream parameters. Note that we rely on peek_si to | 345 /* Determine the stream parameters. Note that we rely on peek_si to |
337 * validate that we have a buffer that does not wrap around the top | 346 * validate that we have a buffer that does not wrap around the top |
338 * of the heap. | 347 * of the heap. |
339 */ | 348 */ |
340 w = ctx->si.w; | 349 w = ctx->si.w; |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 *iter = img; | 559 *iter = img; |
551 } | 560 } |
552 } | 561 } |
553 | 562 |
554 return img; | 563 return img; |
555 } | 564 } |
556 | 565 |
557 static vpx_codec_err_t image2yuvconfig(const vpx_image_t *img, | 566 static vpx_codec_err_t image2yuvconfig(const vpx_image_t *img, |
558 YV12_BUFFER_CONFIG *yv12) | 567 YV12_BUFFER_CONFIG *yv12) |
559 { | 568 { |
| 569 const int y_w = img->d_w; |
| 570 const int y_h = img->d_h; |
| 571 const int uv_w = (img->d_w + 1) / 2; |
| 572 const int uv_h = (img->d_h + 1) / 2; |
560 vpx_codec_err_t res = VPX_CODEC_OK; | 573 vpx_codec_err_t res = VPX_CODEC_OK; |
561 yv12->y_buffer = img->planes[VPX_PLANE_Y]; | 574 yv12->y_buffer = img->planes[VPX_PLANE_Y]; |
562 yv12->u_buffer = img->planes[VPX_PLANE_U]; | 575 yv12->u_buffer = img->planes[VPX_PLANE_U]; |
563 yv12->v_buffer = img->planes[VPX_PLANE_V]; | 576 yv12->v_buffer = img->planes[VPX_PLANE_V]; |
564 | 577 |
565 yv12->y_crop_width = img->d_w; | 578 yv12->y_crop_width = y_w; |
566 yv12->y_crop_height = img->d_h; | 579 yv12->y_crop_height = y_h; |
567 yv12->y_width = img->d_w; | 580 yv12->y_width = y_w; |
568 yv12->y_height = img->d_h; | 581 yv12->y_height = y_h; |
569 yv12->uv_width = yv12->y_width / 2; | 582 yv12->uv_crop_width = uv_w; |
570 yv12->uv_height = yv12->y_height / 2; | 583 yv12->uv_crop_height = uv_h; |
| 584 yv12->uv_width = uv_w; |
| 585 yv12->uv_height = uv_h; |
571 | 586 |
572 yv12->y_stride = img->stride[VPX_PLANE_Y]; | 587 yv12->y_stride = img->stride[VPX_PLANE_Y]; |
573 yv12->uv_stride = img->stride[VPX_PLANE_U]; | 588 yv12->uv_stride = img->stride[VPX_PLANE_U]; |
574 | 589 |
575 yv12->border = (img->stride[VPX_PLANE_Y] - img->d_w) / 2; | 590 yv12->border = (img->stride[VPX_PLANE_Y] - img->d_w) / 2; |
576 return res; | 591 return res; |
577 } | 592 } |
578 | 593 |
579 | 594 |
580 static vpx_codec_err_t vp8_set_reference(vpx_codec_alg_priv_t *ctx, | 595 static vpx_codec_err_t vp8_set_reference(vpx_codec_alg_priv_t *ctx, |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
730 | 745 |
731 static vpx_codec_err_t vp8_get_frame_corrupted(vpx_codec_alg_priv_t *ctx, | 746 static vpx_codec_err_t vp8_get_frame_corrupted(vpx_codec_alg_priv_t *ctx, |
732 va_list args) | 747 va_list args) |
733 { | 748 { |
734 | 749 |
735 int *corrupted = va_arg(args, int *); | 750 int *corrupted = va_arg(args, int *); |
736 VP8D_COMP *pbi = (VP8D_COMP *)ctx->yv12_frame_buffers.pbi[0]; | 751 VP8D_COMP *pbi = (VP8D_COMP *)ctx->yv12_frame_buffers.pbi[0]; |
737 | 752 |
738 if (corrupted && pbi) | 753 if (corrupted && pbi) |
739 { | 754 { |
740 *corrupted = pbi->common.frame_to_show->corrupted; | 755 const YV12_BUFFER_CONFIG *const frame = pbi->common.frame_to_show; |
741 | 756 if (frame == NULL) return VPX_CODEC_ERROR; |
| 757 *corrupted = frame->corrupted; |
742 return VPX_CODEC_OK; | 758 return VPX_CODEC_OK; |
743 } | 759 } |
744 else | 760 else |
745 return VPX_CODEC_INVALID_PARAM; | 761 return VPX_CODEC_INVALID_PARAM; |
746 | 762 |
747 } | 763 } |
748 | 764 |
749 static vpx_codec_err_t vp8_set_decryptor(vpx_codec_alg_priv_t *ctx, | 765 static vpx_codec_err_t vp8_set_decryptor(vpx_codec_alg_priv_t *ctx, |
750 va_list args) | 766 va_list args) |
751 { | 767 { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
787 CODEC_INTERFACE(vpx_codec_vp8_dx) = | 803 CODEC_INTERFACE(vpx_codec_vp8_dx) = |
788 { | 804 { |
789 "WebM Project VP8 Decoder" VERSION_STRING, | 805 "WebM Project VP8 Decoder" VERSION_STRING, |
790 VPX_CODEC_INTERNAL_ABI_VERSION, | 806 VPX_CODEC_INTERNAL_ABI_VERSION, |
791 VPX_CODEC_CAP_DECODER | VP8_CAP_POSTPROC | VP8_CAP_ERROR_CONCEALMENT | | 807 VPX_CODEC_CAP_DECODER | VP8_CAP_POSTPROC | VP8_CAP_ERROR_CONCEALMENT | |
792 VPX_CODEC_CAP_INPUT_FRAGMENTS, | 808 VPX_CODEC_CAP_INPUT_FRAGMENTS, |
793 /* vpx_codec_caps_t caps; */ | 809 /* vpx_codec_caps_t caps; */ |
794 vp8_init, /* vpx_codec_init_fn_t init; */ | 810 vp8_init, /* vpx_codec_init_fn_t init; */ |
795 vp8_destroy, /* vpx_codec_destroy_fn_t destroy; */ | 811 vp8_destroy, /* vpx_codec_destroy_fn_t destroy; */ |
796 vp8_ctf_maps, /* vpx_codec_ctrl_fn_map_t *ctrl_maps; */ | 812 vp8_ctf_maps, /* vpx_codec_ctrl_fn_map_t *ctrl_maps; */ |
797 NOT_IMPLEMENTED, /* vpx_codec_get_mmap_fn_t get_mmap; */ | |
798 NOT_IMPLEMENTED, /* vpx_codec_set_mmap_fn_t set_mmap; */ | |
799 { | 813 { |
800 vp8_peek_si, /* vpx_codec_peek_si_fn_t peek_si; */ | 814 vp8_peek_si, /* vpx_codec_peek_si_fn_t peek_si; */ |
801 vp8_get_si, /* vpx_codec_get_si_fn_t get_si; */ | 815 vp8_get_si, /* vpx_codec_get_si_fn_t get_si; */ |
802 vp8_decode, /* vpx_codec_decode_fn_t decode; */ | 816 vp8_decode, /* vpx_codec_decode_fn_t decode; */ |
803 vp8_get_frame, /* vpx_codec_frame_get_fn_t frame_get; */ | 817 vp8_get_frame, /* vpx_codec_frame_get_fn_t frame_get; */ |
804 NOT_IMPLEMENTED, | 818 NOT_IMPLEMENTED, |
805 }, | 819 }, |
806 { /* encoder functions */ | 820 { /* encoder functions */ |
| 821 0, |
807 NOT_IMPLEMENTED, | 822 NOT_IMPLEMENTED, |
808 NOT_IMPLEMENTED, | 823 NOT_IMPLEMENTED, |
809 NOT_IMPLEMENTED, | 824 NOT_IMPLEMENTED, |
810 NOT_IMPLEMENTED, | 825 NOT_IMPLEMENTED, |
811 NOT_IMPLEMENTED, | 826 NOT_IMPLEMENTED, |
812 NOT_IMPLEMENTED | 827 NOT_IMPLEMENTED |
813 } | 828 } |
814 }; | 829 }; |
OLD | NEW |