Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(128)

Side by Side Diff: source/libvpx/vp8/decoder/decodframe.c

Issue 12982023: libvpx: Pull from upstream (Closed) Base URL: https://src.chromium.org/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « source/libvpx/vp8/common/x86/postproc_mmx.asm ('k') | source/libvpx/vp8/encoder/rdopt.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 875 matching lines...) Expand 10 before | Expand all | Expand 10 after
886 } 886 }
887 } 887 }
888 } 888 }
889 889
890 pbi->fragments.count = num_token_partitions + 1; 890 pbi->fragments.count = num_token_partitions + 1;
891 891
892 for (partition_idx = 1; partition_idx < pbi->fragments.count; ++partition_id x) 892 for (partition_idx = 1; partition_idx < pbi->fragments.count; ++partition_id x)
893 { 893 {
894 if (vp8dx_start_decode(bool_decoder, 894 if (vp8dx_start_decode(bool_decoder,
895 pbi->fragments.ptrs[partition_idx], 895 pbi->fragments.ptrs[partition_idx],
896 pbi->fragments.sizes[partition_idx])) 896 pbi->fragments.sizes[partition_idx],
897 pbi->fragments.ptrs[0],
898 pbi->decrypt_key))
897 vpx_internal_error(&pbi->common.error, VPX_CODEC_MEM_ERROR, 899 vpx_internal_error(&pbi->common.error, VPX_CODEC_MEM_ERROR,
898 "Failed to allocate bool decoder %d", 900 "Failed to allocate bool decoder %d",
899 partition_idx); 901 partition_idx);
900 902
901 bool_decoder++; 903 bool_decoder++;
902 } 904 }
903 905
904 #if CONFIG_MULTITHREAD 906 #if CONFIG_MULTITHREAD
905 /* Clamp number of decoder threads */ 907 /* Clamp number of decoder threads */
906 if (pbi->decoding_thread_count > num_token_partitions - 1) 908 if (pbi->decoding_thread_count > num_token_partitions - 1)
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
973 xd->corrupted = 0; /* init without corruption */ 975 xd->corrupted = 0; /* init without corruption */
974 976
975 xd->fullpixel_mask = 0xffffffff; 977 xd->fullpixel_mask = 0xffffffff;
976 if(pc->full_pixel) 978 if(pc->full_pixel)
977 xd->fullpixel_mask = 0xfffffff8; 979 xd->fullpixel_mask = 0xfffffff8;
978 980
979 } 981 }
980 982
981 int vp8_decode_frame(VP8D_COMP *pbi) 983 int vp8_decode_frame(VP8D_COMP *pbi)
982 { 984 {
983 vp8_reader *const bc = & pbi->mbc[8]; 985 vp8_reader *const bc = &pbi->mbc[8];
984 VP8_COMMON *const pc = & pbi->common; 986 VP8_COMMON *const pc = &pbi->common;
985 MACROBLOCKD *const xd = & pbi->mb; 987 MACROBLOCKD *const xd = &pbi->mb;
986 const unsigned char *data = pbi->fragments.ptrs[0]; 988 const unsigned char *data = pbi->fragments.ptrs[0];
989 const unsigned char *const origin = data;
987 const unsigned char *data_end = data + pbi->fragments.sizes[0]; 990 const unsigned char *data_end = data + pbi->fragments.sizes[0];
988 ptrdiff_t first_partition_length_in_bytes; 991 ptrdiff_t first_partition_length_in_bytes;
989 992
990 int i, j, k, l; 993 int i, j, k, l;
991 const int *const mb_feature_data_bits = vp8_mb_feature_data_bits; 994 const int *const mb_feature_data_bits = vp8_mb_feature_data_bits;
992 int corrupt_tokens = 0; 995 int corrupt_tokens = 0;
993 int prev_independent_partitions = pbi->independent_partitions; 996 int prev_independent_partitions = pbi->independent_partitions;
994 997
995 YV12_BUFFER_CONFIG *yv12_fb_new = pbi->dec_fb_ref[INTRA_FRAME]; 998 YV12_BUFFER_CONFIG *yv12_fb_new = pbi->dec_fb_ref[INTRA_FRAME];
996 999
(...skipping 12 matching lines...) Expand all
1009 /* Declare the missing frame as an inter frame since it will 1012 /* Declare the missing frame as an inter frame since it will
1010 be handled as an inter frame when we have estimated its 1013 be handled as an inter frame when we have estimated its
1011 motion vectors. */ 1014 motion vectors. */
1012 pc->frame_type = INTER_FRAME; 1015 pc->frame_type = INTER_FRAME;
1013 pc->version = 0; 1016 pc->version = 0;
1014 pc->show_frame = 1; 1017 pc->show_frame = 1;
1015 first_partition_length_in_bytes = 0; 1018 first_partition_length_in_bytes = 0;
1016 } 1019 }
1017 else 1020 else
1018 { 1021 {
1019 pc->frame_type = (FRAME_TYPE)(data[0] & 1); 1022 const unsigned char data0 = decrypt_byte(data + 0, origin,
1020 pc->version = (data[0] >> 1) & 7; 1023 pbi->decrypt_key);
1021 pc->show_frame = (data[0] >> 4) & 1; 1024 const unsigned char data1 = decrypt_byte(data + 1, origin,
1025 pbi->decrypt_key);
1026 const unsigned char data2 = decrypt_byte(data + 2, origin,
1027 pbi->decrypt_key);
1028
1029 pc->frame_type = (FRAME_TYPE)(data0 & 1);
1030 pc->version = (data0 >> 1) & 7;
1031 pc->show_frame = (data0 >> 4) & 1;
1022 first_partition_length_in_bytes = 1032 first_partition_length_in_bytes =
1023 (data[0] | (data[1] << 8) | (data[2] << 16)) >> 5; 1033 (data0 | (data1 << 8) | (data2 << 16)) >> 5;
1024 1034
1025 if (!pbi->ec_active && (data + first_partition_length_in_bytes > data_en d 1035 if (!pbi->ec_active &&
1036 (data + first_partition_length_in_bytes > data_end
1026 || data + first_partition_length_in_bytes < data)) 1037 || data + first_partition_length_in_bytes < data))
1027 vpx_internal_error(&pc->error, VPX_CODEC_CORRUPT_FRAME, 1038 vpx_internal_error(&pc->error, VPX_CODEC_CORRUPT_FRAME,
1028 "Truncated packet or corrupt partition 0 length") ; 1039 "Truncated packet or corrupt partition 0 length") ;
1029 1040
1030 data += 3; 1041 data += 3;
1031 1042
1032 vp8_setup_version(pc); 1043 vp8_setup_version(pc);
1033 1044
1034 1045
1035 if (pc->frame_type == KEY_FRAME) 1046 if (pc->frame_type == KEY_FRAME)
1036 { 1047 {
1037 /* vet via sync code */ 1048 /* vet via sync code */
1038 /* When error concealment is enabled we should only check the sync 1049 /* When error concealment is enabled we should only check the sync
1039 * code if we have enough bits available 1050 * code if we have enough bits available
1040 */ 1051 */
1041 if (!pbi->ec_active || data + 3 < data_end) 1052 if (!pbi->ec_active || data + 3 < data_end)
1042 { 1053 {
1043 if (data[0] != 0x9d || data[1] != 0x01 || data[2] != 0x2a) 1054 const unsigned char data0 = decrypt_byte(data + 0, origin,
1055 pbi->decrypt_key);
1056 const unsigned char data1 = decrypt_byte(data + 1, origin,
1057 pbi->decrypt_key);
1058 const unsigned char data2 = decrypt_byte(data + 2, origin,
1059 pbi->decrypt_key);
1060 if (data0 != 0x9d || data1 != 0x01 || data2 != 0x2a)
1044 vpx_internal_error(&pc->error, VPX_CODEC_UNSUP_BITSTREAM, 1061 vpx_internal_error(&pc->error, VPX_CODEC_UNSUP_BITSTREAM,
1045 "Invalid frame sync code"); 1062 "Invalid frame sync code");
1046 } 1063 }
1047 1064
1048 /* If error concealment is enabled we should only parse the new size 1065 /* If error concealment is enabled we should only parse the new size
1049 * if we have enough data. Otherwise we will end up with the wrong 1066 * if we have enough data. Otherwise we will end up with the wrong
1050 * size. 1067 * size.
1051 */ 1068 */
1052 if (!pbi->ec_active || data + 6 < data_end) 1069 if (!pbi->ec_active || data + 6 < data_end)
1053 { 1070 {
1054 pc->Width = (data[3] | (data[4] << 8)) & 0x3fff; 1071 const unsigned char data3 = decrypt_byte(data + 3, origin,
1055 pc->horiz_scale = data[4] >> 6; 1072 pbi->decrypt_key);
1056 pc->Height = (data[5] | (data[6] << 8)) & 0x3fff; 1073 const unsigned char data4 = decrypt_byte(data + 4, origin,
1057 pc->vert_scale = data[6] >> 6; 1074 pbi->decrypt_key);
1075 const unsigned char data5 = decrypt_byte(data + 5, origin,
1076 pbi->decrypt_key);
1077 const unsigned char data6 = decrypt_byte(data + 6, origin,
1078 pbi->decrypt_key);
1079
1080 pc->Width = (data3 | (data4 << 8)) & 0x3fff;
1081 pc->horiz_scale = data4 >> 6;
1082 pc->Height = (data5 | (data6 << 8)) & 0x3fff;
1083 pc->vert_scale = data6 >> 6;
1058 } 1084 }
1059 data += 7; 1085 data += 7;
1060 1086
1061 } 1087 }
1062 else 1088 else
1063 { 1089 {
1064 vpx_memcpy(&xd->pre, yv12_fb_new, sizeof(YV12_BUFFER_CONFIG)); 1090 vpx_memcpy(&xd->pre, yv12_fb_new, sizeof(YV12_BUFFER_CONFIG));
1065 vpx_memcpy(&xd->dst, yv12_fb_new, sizeof(YV12_BUFFER_CONFIG)); 1091 vpx_memcpy(&xd->dst, yv12_fb_new, sizeof(YV12_BUFFER_CONFIG));
1066 } 1092 }
1067 } 1093 }
1068 if ((!pbi->decoded_key_frame && pc->frame_type != KEY_FRAME)) 1094 if ((!pbi->decoded_key_frame && pc->frame_type != KEY_FRAME))
1069 { 1095 {
1070 return -1; 1096 return -1;
1071 } 1097 }
1072 1098
1073 init_frame(pbi); 1099 init_frame(pbi);
1074 1100
1075 if (vp8dx_start_decode(bc, data, (unsigned int)(data_end - data))) 1101 if (vp8dx_start_decode(bc,
1102 data,
1103 (unsigned int)(data_end - data),
1104 pbi->fragments.ptrs[0],
1105 pbi->decrypt_key))
1076 vpx_internal_error(&pc->error, VPX_CODEC_MEM_ERROR, 1106 vpx_internal_error(&pc->error, VPX_CODEC_MEM_ERROR,
1077 "Failed to allocate bool decoder 0"); 1107 "Failed to allocate bool decoder 0");
1078 if (pc->frame_type == KEY_FRAME) { 1108 if (pc->frame_type == KEY_FRAME) {
1079 pc->clr_type = (YUV_TYPE)vp8_read_bit(bc); 1109 pc->clr_type = (YUV_TYPE)vp8_read_bit(bc);
1080 pc->clamp_type = (CLAMP_TYPE)vp8_read_bit(bc); 1110 pc->clamp_type = (CLAMP_TYPE)vp8_read_bit(bc);
1081 } 1111 }
1082 1112
1083 /* Is segmentation enabled */ 1113 /* Is segmentation enabled */
1084 xd->segmentation_enabled = (unsigned char)vp8_read_bit(bc); 1114 xd->segmentation_enabled = (unsigned char)vp8_read_bit(bc);
1085 1115
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
1377 FILE *f = fopen("decompressor.VP8", "ab"); 1407 FILE *f = fopen("decompressor.VP8", "ab");
1378 unsigned int size = pbi->bc2.pos + pbi->bc.pos + 8; 1408 unsigned int size = pbi->bc2.pos + pbi->bc.pos + 8;
1379 fwrite((void *) &size, 4, 1, f); 1409 fwrite((void *) &size, 4, 1, f);
1380 fwrite((void *) pbi->Source, size, 1, f); 1410 fwrite((void *) pbi->Source, size, 1, f);
1381 fclose(f); 1411 fclose(f);
1382 } 1412 }
1383 #endif 1413 #endif
1384 1414
1385 return 0; 1415 return 0;
1386 } 1416 }
OLDNEW
« no previous file with comments | « source/libvpx/vp8/common/x86/postproc_mmx.asm ('k') | source/libvpx/vp8/encoder/rdopt.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698