Skip to content

Commit bcb065b

Browse files
authored
Refactor vp8 functionality into lossy module (#172)
1 parent 608fe79 commit bcb065b

13 files changed

Lines changed: 41 additions & 68 deletions

src/decoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::ops::Range;
99
use crate::extended::{self, get_alpha_predictor, read_alpha_chunk, WebPExtendedInfo};
1010

1111
use super::lossless::LosslessDecoder;
12-
use super::vp8::Vp8Decoder;
12+
use super::lossy::Vp8Decoder;
1313

1414
quick_error! {
1515
/// Errors that can occur when attempting to decode a WebP image

src/encoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::slice::ChunksExact;
55

66
use quick_error::quick_error;
77

8-
use crate::vp8_encoder::encode_frame_lossy;
8+
use crate::lossy::encoder::encode_frame_lossy;
99

1010
/// Color type of the image.
1111
///

src/lib.rs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,21 @@ mod decoder;
1919
mod encoder;
2020
mod extended;
2121
mod huffman;
22-
mod loop_filter;
2322
mod lossless;
2423
mod lossless_transform;
25-
mod transform;
26-
mod vp8_arithmetic_decoder;
27-
mod vp8_arithmetic_encoder;
28-
mod vp8_common;
29-
mod vp8_encoder;
30-
mod vp8_prediction;
31-
mod yuv;
24+
mod lossy;
3225

33-
pub mod vp8;
26+
/// An implementation of the VP8 Video Codec
27+
///
28+
/// This module contains a partial implementation of the
29+
/// VP8 video format as defined in RFC-6386.
30+
///
31+
/// It decodes Keyframes only.
32+
/// VP8 is the underpinning of the WebP image format
33+
///
34+
/// # Related Links
35+
/// * [rfc-6386](http://tools.ietf.org/html/rfc6386) - The VP8 Data Format and Decoding Guide
36+
/// * [VP8.pdf](http://static.googleusercontent.com/media/research.google.com/en//pubs/archive/37073.pdf) - An overview of of the VP8 format
37+
pub mod vp8 {
38+
pub use crate::lossy::{Frame, Vp8Decoder};
39+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::decoder::DecodingError;
22

3-
use super::vp8::TreeNode;
3+
use super::TreeNode;
44

55
#[must_use]
66
#[repr(transparent)]
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,8 @@ impl ArithmeticEncoder {
163163

164164
#[cfg(test)]
165165
mod tests {
166-
use crate::vp8_arithmetic_decoder::ArithmeticDecoder;
167-
use crate::vp8_common::*;
166+
use crate::lossy::arithmetic_decoder::ArithmeticDecoder;
167+
use crate::lossy::common::*;
168168

169169
use super::*;
170170

File renamed without changes.
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ use std::io::Write;
22

33
use byteorder_lite::{LittleEndian, WriteBytesExt};
44

5-
use crate::transform;
6-
use crate::vp8::Frame;
7-
use crate::vp8_arithmetic_encoder::ArithmeticEncoder;
8-
use crate::vp8_common::*;
9-
use crate::vp8_prediction::*;
10-
use crate::yuv::convert_image_y;
11-
use crate::yuv::convert_image_yuv;
5+
use super::arithmetic_encoder::ArithmeticEncoder;
6+
use super::common::*;
7+
use super::prediction::*;
8+
use super::transform;
9+
use super::yuv::convert_image_y;
10+
use super::yuv::convert_image_yuv;
11+
use super::Frame;
1212
use crate::ColorType;
1313
use crate::EncodingError;
1414

src/vp8.rs renamed to src/lossy/mod.rs

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,21 @@
1-
//! An implementation of the VP8 Video Codec
2-
//!
3-
//! This module contains a partial implementation of the
4-
//! VP8 video format as defined in RFC-6386.
5-
//!
6-
//! It decodes Keyframes only.
7-
//! VP8 is the underpinning of the WebP image format
8-
//!
9-
//! # Related Links
10-
//! * [rfc-6386](http://tools.ietf.org/html/rfc6386) - The VP8 Data Format and Decoding Guide
11-
//! * [VP8.pdf](http://static.googleusercontent.com/media/research.google.com/en//pubs/archive/37073.pdf) - An overview of of the VP8 format
12-
131
use byteorder_lite::{LittleEndian, ReadBytesExt};
142
use std::default::Default;
153
use std::io::Read;
164

175
use crate::decoder::{DecodingError, UpsamplingMethod};
18-
use crate::vp8_common::*;
19-
use crate::vp8_prediction::*;
20-
use crate::yuv;
21-
22-
use super::vp8_arithmetic_decoder::ArithmeticDecoder;
23-
use super::{loop_filter, transform};
6+
use common::*;
7+
use prediction::*;
8+
9+
use arithmetic_decoder::ArithmeticDecoder;
10+
11+
mod arithmetic_decoder;
12+
mod arithmetic_encoder;
13+
mod common;
14+
pub(crate) mod encoder;
15+
mod loop_filter;
16+
mod prediction;
17+
mod transform;
18+
mod yuv;
2419

2520
#[derive(Clone, Copy)]
2621
pub(crate) struct TreeNode {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//!
33
//! Functions for doing prediction and for setting up buffers for prediction
44
5-
use crate::vp8_common::IntraMode;
5+
use super::common::IntraMode;
66

77
/// Luma prediction block includes the 1 pixel border to the left and on top
88
/// as well as 4 pixels to the top right of the block

0 commit comments

Comments
 (0)