| 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 |
| 11 #include <stdlib.h> | 11 #include <stdlib.h> |
| 12 #include <string.h> | 12 #include <string.h> |
| 13 | 13 |
| 14 #include "./vpx_config.h" |
| 14 #include "./vpx_version.h" | 15 #include "./vpx_version.h" |
| 15 | 16 |
| 16 #include "vpx/internal/vpx_codec_internal.h" | 17 #include "vpx/internal/vpx_codec_internal.h" |
| 17 #include "vpx/vp8dx.h" | 18 #include "vpx/vp8dx.h" |
| 18 #include "vpx/vpx_decoder.h" | 19 #include "vpx/vpx_decoder.h" |
| 19 | 20 |
| 20 #include "vp9/common/vp9_frame_buffers.h" | 21 #include "vp9/common/vp9_frame_buffers.h" |
| 21 | 22 |
| 22 #include "vp9/decoder/vp9_decoder.h" | 23 #include "vp9/decoder/vp9_decoder.h" |
| 23 #include "vp9/decoder/vp9_decodeframe.h" | 24 #include "vp9/decoder/vp9_decodeframe.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 36 struct VP9Decoder *pbi; | 37 struct VP9Decoder *pbi; |
| 37 int postproc_cfg_set; | 38 int postproc_cfg_set; |
| 38 vp8_postproc_cfg_t postproc_cfg; | 39 vp8_postproc_cfg_t postproc_cfg; |
| 39 vpx_decrypt_cb decrypt_cb; | 40 vpx_decrypt_cb decrypt_cb; |
| 40 void *decrypt_state; | 41 void *decrypt_state; |
| 41 vpx_image_t img; | 42 vpx_image_t img; |
| 42 int img_avail; | 43 int img_avail; |
| 43 int flushed; | 44 int flushed; |
| 44 int invert_tile_order; | 45 int invert_tile_order; |
| 45 int frame_parallel_decode; // frame-based threading. | 46 int frame_parallel_decode; // frame-based threading. |
| 47 int byte_alignment; |
| 46 | 48 |
| 47 // External frame buffer info to save for VP9 common. | 49 // External frame buffer info to save for VP9 common. |
| 48 void *ext_priv; // Private data associated with the external frame buffers. | 50 void *ext_priv; // Private data associated with the external frame buffers. |
| 49 vpx_get_frame_buffer_cb_fn_t get_ext_fb_cb; | 51 vpx_get_frame_buffer_cb_fn_t get_ext_fb_cb; |
| 50 vpx_release_frame_buffer_cb_fn_t release_ext_fb_cb; | 52 vpx_release_frame_buffer_cb_fn_t release_ext_fb_cb; |
| 51 }; | 53 }; |
| 52 | 54 |
| 53 static vpx_codec_err_t decoder_init(vpx_codec_ctx_t *ctx, | 55 static vpx_codec_err_t decoder_init(vpx_codec_ctx_t *ctx, |
| 54 vpx_codec_priv_enc_mr_cfg_t *data) { | 56 vpx_codec_priv_enc_mr_cfg_t *data) { |
| 55 // This function only allocates space for the vpx_codec_alg_priv_t | 57 // This function only allocates space for the vpx_codec_alg_priv_t |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 { | 141 { |
| 140 int show_frame; | 142 int show_frame; |
| 141 int error_resilient; | 143 int error_resilient; |
| 142 struct vp9_read_bit_buffer rb = { data, data + data_sz, 0, NULL, NULL }; | 144 struct vp9_read_bit_buffer rb = { data, data + data_sz, 0, NULL, NULL }; |
| 143 const int frame_marker = vp9_rb_read_literal(&rb, 2); | 145 const int frame_marker = vp9_rb_read_literal(&rb, 2); |
| 144 const BITSTREAM_PROFILE profile = vp9_read_profile(&rb); | 146 const BITSTREAM_PROFILE profile = vp9_read_profile(&rb); |
| 145 | 147 |
| 146 if (frame_marker != VP9_FRAME_MARKER) | 148 if (frame_marker != VP9_FRAME_MARKER) |
| 147 return VPX_CODEC_UNSUP_BITSTREAM; | 149 return VPX_CODEC_UNSUP_BITSTREAM; |
| 148 | 150 |
| 149 if (profile >= MAX_PROFILES) return VPX_CODEC_UNSUP_BITSTREAM; | 151 if (profile >= MAX_PROFILES) |
| 152 return VPX_CODEC_UNSUP_BITSTREAM; |
| 153 |
| 154 if ((profile >= 2 && data_sz <= 1) || data_sz < 1) |
| 155 return VPX_CODEC_UNSUP_BITSTREAM; |
| 150 | 156 |
| 151 if (vp9_rb_read_bit(&rb)) { // show an existing frame | 157 if (vp9_rb_read_bit(&rb)) { // show an existing frame |
| 152 vp9_rb_read_literal(&rb, 3); // Frame buffer to show. | 158 vp9_rb_read_literal(&rb, 3); // Frame buffer to show. |
| 153 return VPX_CODEC_OK; | 159 return VPX_CODEC_OK; |
| 154 } | 160 } |
| 155 | 161 |
| 156 if (data_sz <= 8) | 162 if (data_sz <= 8) |
| 157 return VPX_CODEC_UNSUP_BITSTREAM; | 163 return VPX_CODEC_UNSUP_BITSTREAM; |
| 158 | 164 |
| 159 si->is_kf = !vp9_rb_read_bit(&rb); | 165 si->is_kf = !vp9_rb_read_bit(&rb); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 if (error->error_code) | 217 if (error->error_code) |
| 212 ctx->base.err_detail = error->has_detail ? error->detail : NULL; | 218 ctx->base.err_detail = error->has_detail ? error->detail : NULL; |
| 213 | 219 |
| 214 return error->error_code; | 220 return error->error_code; |
| 215 } | 221 } |
| 216 | 222 |
| 217 static void init_buffer_callbacks(vpx_codec_alg_priv_t *ctx) { | 223 static void init_buffer_callbacks(vpx_codec_alg_priv_t *ctx) { |
| 218 VP9_COMMON *const cm = &ctx->pbi->common; | 224 VP9_COMMON *const cm = &ctx->pbi->common; |
| 219 | 225 |
| 220 cm->new_fb_idx = -1; | 226 cm->new_fb_idx = -1; |
| 227 cm->byte_alignment = ctx->byte_alignment; |
| 221 | 228 |
| 222 if (ctx->get_ext_fb_cb != NULL && ctx->release_ext_fb_cb != NULL) { | 229 if (ctx->get_ext_fb_cb != NULL && ctx->release_ext_fb_cb != NULL) { |
| 223 cm->get_fb_cb = ctx->get_ext_fb_cb; | 230 cm->get_fb_cb = ctx->get_ext_fb_cb; |
| 224 cm->release_fb_cb = ctx->release_ext_fb_cb; | 231 cm->release_fb_cb = ctx->release_ext_fb_cb; |
| 225 cm->cb_priv = ctx->ext_priv; | 232 cm->cb_priv = ctx->ext_priv; |
| 226 } else { | 233 } else { |
| 227 cm->get_fb_cb = vp9_get_frame_buffer; | 234 cm->get_fb_cb = vp9_get_frame_buffer; |
| 228 cm->release_fb_cb = vp9_release_frame_buffer; | 235 cm->release_fb_cb = vp9_release_frame_buffer; |
| 229 | 236 |
| 230 if (vp9_alloc_internal_frame_buffers(&cm->int_frame_buffers)) | 237 if (vp9_alloc_internal_frame_buffers(&cm->int_frame_buffers)) |
| (...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 609 } | 616 } |
| 610 | 617 |
| 611 static vpx_codec_err_t ctrl_set_decryptor(vpx_codec_alg_priv_t *ctx, | 618 static vpx_codec_err_t ctrl_set_decryptor(vpx_codec_alg_priv_t *ctx, |
| 612 va_list args) { | 619 va_list args) { |
| 613 vpx_decrypt_init *init = va_arg(args, vpx_decrypt_init *); | 620 vpx_decrypt_init *init = va_arg(args, vpx_decrypt_init *); |
| 614 ctx->decrypt_cb = init ? init->decrypt_cb : NULL; | 621 ctx->decrypt_cb = init ? init->decrypt_cb : NULL; |
| 615 ctx->decrypt_state = init ? init->decrypt_state : NULL; | 622 ctx->decrypt_state = init ? init->decrypt_state : NULL; |
| 616 return VPX_CODEC_OK; | 623 return VPX_CODEC_OK; |
| 617 } | 624 } |
| 618 | 625 |
| 626 static vpx_codec_err_t ctrl_set_byte_alignment(vpx_codec_alg_priv_t *ctx, |
| 627 va_list args) { |
| 628 const int legacy_byte_alignment = 0; |
| 629 const int min_byte_alignment = 32; |
| 630 const int max_byte_alignment = 1024; |
| 631 const int byte_alignment = va_arg(args, int); |
| 632 |
| 633 if (byte_alignment != legacy_byte_alignment && |
| 634 (byte_alignment < min_byte_alignment || |
| 635 byte_alignment > max_byte_alignment || |
| 636 (byte_alignment & (byte_alignment - 1)) != 0)) |
| 637 return VPX_CODEC_INVALID_PARAM; |
| 638 |
| 639 ctx->byte_alignment = byte_alignment; |
| 640 if (ctx->pbi != NULL) { |
| 641 VP9_COMMON *const cm = &ctx->pbi->common; |
| 642 cm->byte_alignment = byte_alignment; |
| 643 } |
| 644 return VPX_CODEC_OK; |
| 645 } |
| 646 |
| 619 static vpx_codec_ctrl_fn_map_t decoder_ctrl_maps[] = { | 647 static vpx_codec_ctrl_fn_map_t decoder_ctrl_maps[] = { |
| 620 {VP8_COPY_REFERENCE, ctrl_copy_reference}, | 648 {VP8_COPY_REFERENCE, ctrl_copy_reference}, |
| 621 | 649 |
| 622 // Setters | 650 // Setters |
| 623 {VP8_SET_REFERENCE, ctrl_set_reference}, | 651 {VP8_SET_REFERENCE, ctrl_set_reference}, |
| 624 {VP8_SET_POSTPROC, ctrl_set_postproc}, | 652 {VP8_SET_POSTPROC, ctrl_set_postproc}, |
| 625 {VP8_SET_DBG_COLOR_REF_FRAME, ctrl_set_dbg_options}, | 653 {VP8_SET_DBG_COLOR_REF_FRAME, ctrl_set_dbg_options}, |
| 626 {VP8_SET_DBG_COLOR_MB_MODES, ctrl_set_dbg_options}, | 654 {VP8_SET_DBG_COLOR_MB_MODES, ctrl_set_dbg_options}, |
| 627 {VP8_SET_DBG_COLOR_B_MODES, ctrl_set_dbg_options}, | 655 {VP8_SET_DBG_COLOR_B_MODES, ctrl_set_dbg_options}, |
| 628 {VP8_SET_DBG_DISPLAY_MV, ctrl_set_dbg_options}, | 656 {VP8_SET_DBG_DISPLAY_MV, ctrl_set_dbg_options}, |
| 629 {VP9_INVERT_TILE_DECODE_ORDER, ctrl_set_invert_tile_order}, | 657 {VP9_INVERT_TILE_DECODE_ORDER, ctrl_set_invert_tile_order}, |
| 630 {VPXD_SET_DECRYPTOR, ctrl_set_decryptor}, | 658 {VPXD_SET_DECRYPTOR, ctrl_set_decryptor}, |
| 659 {VP9_SET_BYTE_ALIGNMENT, ctrl_set_byte_alignment}, |
| 631 | 660 |
| 632 // Getters | 661 // Getters |
| 633 {VP8D_GET_LAST_REF_UPDATES, ctrl_get_last_ref_updates}, | 662 {VP8D_GET_LAST_REF_UPDATES, ctrl_get_last_ref_updates}, |
| 634 {VP8D_GET_FRAME_CORRUPTED, ctrl_get_frame_corrupted}, | 663 {VP8D_GET_FRAME_CORRUPTED, ctrl_get_frame_corrupted}, |
| 635 {VP9_GET_REFERENCE, ctrl_get_reference}, | 664 {VP9_GET_REFERENCE, ctrl_get_reference}, |
| 636 {VP9D_GET_DISPLAY_SIZE, ctrl_get_display_size}, | 665 {VP9D_GET_DISPLAY_SIZE, ctrl_get_display_size}, |
| 637 {VP9D_GET_BIT_DEPTH, ctrl_get_bit_depth}, | 666 {VP9D_GET_BIT_DEPTH, ctrl_get_bit_depth}, |
| 638 | 667 |
| 639 { -1, NULL}, | 668 { -1, NULL}, |
| 640 }; | 669 }; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 661 0, | 690 0, |
| 662 NULL, // vpx_codec_enc_cfg_map_t | 691 NULL, // vpx_codec_enc_cfg_map_t |
| 663 NULL, // vpx_codec_encode_fn_t | 692 NULL, // vpx_codec_encode_fn_t |
| 664 NULL, // vpx_codec_get_cx_data_fn_t | 693 NULL, // vpx_codec_get_cx_data_fn_t |
| 665 NULL, // vpx_codec_enc_config_set_fn_t | 694 NULL, // vpx_codec_enc_config_set_fn_t |
| 666 NULL, // vpx_codec_get_global_headers_fn_t | 695 NULL, // vpx_codec_get_global_headers_fn_t |
| 667 NULL, // vpx_codec_get_preview_frame_fn_t | 696 NULL, // vpx_codec_get_preview_frame_fn_t |
| 668 NULL // vpx_codec_enc_mr_get_mem_loc_fn_t | 697 NULL // vpx_codec_enc_mr_get_mem_loc_fn_t |
| 669 } | 698 } |
| 670 }; | 699 }; |
| OLD | NEW |