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

Side by Side Diff: source/libvpx/vp9/common/vp9_seg_common.c

Issue 11555023: libvpx: Add VP9 decoder. (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 8 years 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 | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include <assert.h>
12 #include "vp9/common/vp9_blockd.h"
13 #include "vp9/common/vp9_seg_common.h"
14
15 static const int segfeaturedata_signed[SEG_LVL_MAX] = { 1, 1, 0, 0, 0, 0 };
16 static const int seg_feature_data_max[SEG_LVL_MAX] =
17 { MAXQ, 63, 0xf, MB_MODE_COUNT - 1, 255, TX_SIZE_MAX - 1};
18
19 // These functions provide access to new segment level features.
20 // Eventually these function may be "optimized out" but for the moment,
21 // the coding mechanism is still subject to change so these provide a
22 // convenient single point of change.
23
24 int vp9_segfeature_active(const MACROBLOCKD *xd,
25 int segment_id,
26 SEG_LVL_FEATURES feature_id) {
27 // Return true if mask bit set and segmentation enabled.
28 return (xd->segmentation_enabled &&
29 (xd->segment_feature_mask[segment_id] &
30 (0x01 << feature_id)));
31 }
32
33 void vp9_clearall_segfeatures(MACROBLOCKD *xd) {
34 vpx_memset(xd->segment_feature_data, 0, sizeof(xd->segment_feature_data));
35 vpx_memset(xd->segment_feature_mask, 0, sizeof(xd->segment_feature_mask));
36 }
37
38 void vp9_enable_segfeature(MACROBLOCKD *xd,
39 int segment_id,
40 SEG_LVL_FEATURES feature_id) {
41 xd->segment_feature_mask[segment_id] |= (0x01 << feature_id);
42 }
43
44 void vp9_disable_segfeature(MACROBLOCKD *xd,
45 int segment_id,
46 SEG_LVL_FEATURES feature_id) {
47 xd->segment_feature_mask[segment_id] &= ~(1 << feature_id);
48 }
49
50 int vp9_seg_feature_data_max(SEG_LVL_FEATURES feature_id) {
51 return seg_feature_data_max[feature_id];
52 }
53
54 int vp9_is_segfeature_signed(SEG_LVL_FEATURES feature_id) {
55 return (segfeaturedata_signed[feature_id]);
56 }
57
58 void vp9_clear_segdata(MACROBLOCKD *xd,
59 int segment_id,
60 SEG_LVL_FEATURES feature_id) {
61 xd->segment_feature_data[segment_id][feature_id] = 0;
62 }
63
64 void vp9_set_segdata(MACROBLOCKD *xd,
65 int segment_id,
66 SEG_LVL_FEATURES feature_id,
67 int seg_data) {
68 assert(seg_data <= seg_feature_data_max[feature_id]);
69 if (seg_data < 0) {
70 assert(segfeaturedata_signed[feature_id]);
71 assert(-seg_data <= seg_feature_data_max[feature_id]);
72 }
73
74 xd->segment_feature_data[segment_id][feature_id] = seg_data;
75 }
76
77 int vp9_get_segdata(const MACROBLOCKD *xd,
78 int segment_id,
79 SEG_LVL_FEATURES feature_id) {
80 return xd->segment_feature_data[segment_id][feature_id];
81 }
82
83 void vp9_clear_segref(MACROBLOCKD *xd, int segment_id) {
84 xd->segment_feature_data[segment_id][SEG_LVL_REF_FRAME] = 0;
85 }
86
87 void vp9_set_segref(MACROBLOCKD *xd,
88 int segment_id,
89 MV_REFERENCE_FRAME ref_frame) {
90 xd->segment_feature_data[segment_id][SEG_LVL_REF_FRAME] |=
91 (1 << ref_frame);
92 }
93
94 int vp9_check_segref(const MACROBLOCKD *xd,
95 int segment_id,
96 MV_REFERENCE_FRAME ref_frame) {
97 return (xd->segment_feature_data[segment_id][SEG_LVL_REF_FRAME] &
98 (1 << ref_frame)) ? 1 : 0;
99 }
100
101 int vp9_check_segref_inter(MACROBLOCKD *xd, int segment_id) {
102 return (xd->segment_feature_data[segment_id][SEG_LVL_REF_FRAME] &
103 ~(1 << INTRA_FRAME)) ? 1 : 0;
104 }
105
106 int vp9_get_seg_tx_type(MACROBLOCKD *xd, int segment_id) {
107 if (vp9_segfeature_active(xd, segment_id, SEG_LVL_TRANSFORM))
108 return vp9_get_segdata(xd, segment_id, SEG_LVL_TRANSFORM);
109 else
110 return TX_4X4;
111 }
112 // TBD? Functions to read and write segment data with range / validity checking
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698