Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
scanline_interface_frame_adapter.h
Go to the documentation of this file.
1 /*
2  * Copyright 2013 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http:///www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
18 
30 
31 #ifndef PAGESPEED_KERNEL_IMAGE_SCANLINE_INTERFACE_FRAME_ADAPTER_H_
32 #define PAGESPEED_KERNEL_IMAGE_SCANLINE_INTERFACE_FRAME_ADAPTER_H_
33 
34 #include <cstddef>
42 
43 namespace net_instaweb {
44 
45 class MessageHandler;
46 
47 }
48 
49 namespace pagespeed {
50 
51 namespace image_compression {
52 
54 
55 
59  public:
61  explicit FrameToScanlineReaderAdapter(MultipleFrameReader* frame_reader);
62  virtual ~FrameToScanlineReaderAdapter() {}
63 
64  virtual bool Reset();
65  virtual size_t GetBytesPerScanline();
66  virtual bool HasMoreScanLines();
67  virtual bool IsProgressive();
68 
71  virtual ScanlineStatus InitializeWithStatus(const void* image_buffer,
72  size_t buffer_length);
74  void** out_scanline_bytes);
75  virtual size_t GetImageHeight();
76  virtual size_t GetImageWidth();
77  virtual PixelFormat GetPixelFormat();
78 
79  private:
81 
82  ImageSpec image_spec_;
83  FrameSpec frame_spec_;
84 
85 
86 };
87 
91  public:
93  explicit FrameToScanlineWriterAdapter(MultipleFrameWriter* frame_writer);
94  virtual ~FrameToScanlineWriterAdapter() {}
95 
96  virtual ScanlineStatus InitWithStatus(size_t width, size_t height,
97  PixelFormat pixel_format);
98  virtual ScanlineStatus InitializeWriteWithStatus(const void* config,
99  GoogleString* out);
101  const void *scanline_bytes);
103 
104  private:
106 
107  bool init_done_;
108  ImageSpec image_spec_;
109  FrameSpec frame_spec_;
110 
111 
112 };
113 
114 
116 
120  public:
124  virtual ScanlineStatus Reset();
125  virtual ScanlineStatus Initialize();
126  virtual bool HasMoreFrames() const;
127  virtual bool HasMoreScanlines() const;
129  virtual ScanlineStatus ReadNextScanline(const void** out_scanline_bytes);
130  virtual ScanlineStatus GetFrameSpec(FrameSpec* frame_spec) const;
131  virtual ScanlineStatus GetImageSpec(ImageSpec* image_spec) const;
132 
133  private:
134  enum {
135  UNINITIALIZED = 0,
136  INITIALIZED,
137  FRAME_PREPARED,
138 
139  ERROR
140  } state_;
141 
142  ImageSpec image_spec_;
143  FrameSpec frame_spec_;
144 
146 
147 
148 };
149 
153  public:
156  MessageHandler* handler);
157 
158  virtual ScanlineStatus Initialize(const void* config,
159  GoogleString* out);
160  virtual ScanlineStatus PrepareImage(const ImageSpec* image_spec);
161  virtual ScanlineStatus PrepareNextFrame(const FrameSpec* frame_spec);
162  virtual ScanlineStatus WriteNextScanline(const void *scanline_bytes);
163  virtual ScanlineStatus FinalizeWrite();
164 
165  private:
166  enum {
167  UNINITIALIZED = 0,
168  INITIALIZED,
169  IMAGE_PREPARED,
170  FRAME_PREPARED,
171 
172  ERROR
173  } state_;
174  const ImageSpec* image_spec_;
175  const FrameSpec* frame_spec_;
176 
178 
179  const void* config_;
180  GoogleString* out_;
181 
182 
183 };
184 
185 }
186 
187 }
188 
189 #endif
virtual size_t GetImageWidth()
Returns the width of the image.
ScanlineToFrameWriterAdapter(ScanlineWriterInterface *scanline_writer, MessageHandler *handler)
Acquires ownership of 'scanline_writer'.
Definition: scanline_status.h:93
virtual ScanlineStatus ReadNextScanline(const void **out_scanline_bytes)
virtual ScanlineStatus PrepareImage(const ImageSpec *image_spec)
Definition: image_frame_interface.h:146
MessageHandler * message_handler() const
Definition: image_frame_interface.h:203
Definition: image_frame_interface.h:279
virtual ScanlineStatus InitializeWithStatus(const void *image_buffer, size_t buffer_length)
virtual ScanlineStatus PrepareNextFrame(const FrameSpec *frame_spec)
Scanline API to MultipleFrame API adapters.
Definition: scanline_interface_frame_adapter.h:119
MultipleFrame API to Scanline API adapters.
Definition: scanline_interface_frame_adapter.h:58
Definition: scoped_ptr.h:30
std::string GoogleString
PAGESPEED_KERNEL_BASE_STRING_H_.
Definition: string.h:24
Definition: scanline_interface_frame_adapter.h:152
virtual ScanlineStatus FinalizeWriteWithStatus()
Finalizes write structure once all scanlines are written.
virtual ScanlineStatus GetImageSpec(ImageSpec *image_spec) const
virtual ScanlineStatus GetFrameSpec(FrameSpec *frame_spec) const
virtual ScanlineStatus InitWithStatus(size_t width, size_t height, PixelFormat pixel_format)
Initialize the basic parameter for writing the image.
Definition: image_frame_interface.h:43
Definition: image_frame_interface.h:79
virtual ScanlineStatus WriteNextScanlineWithStatus(const void *scanline_bytes)
Definition: scanline_interface_frame_adapter.h:90
virtual size_t GetImageHeight()
Returns the height of the image.
FrameToScanlineReaderAdapter(MultipleFrameReader *frame_reader)
Acquires ownership of 'frame_reader'.
virtual size_t GetBytesPerScanline()
Returns number of bytes that required to store a scanline.
virtual ScanlineStatus Reset()
Resets the MultipleFrameReader to its initial state.
virtual bool HasMoreScanLines()
Returns true if there are more scanlines to read.
Definition: message_handler.h:39
FrameToScanlineWriterAdapter(MultipleFrameWriter *frame_writer)
Acquires ownership of 'frame_writer'.
virtual ScanlineStatus Initialize(const void *config, GoogleString *out)
virtual ScanlineStatus WriteNextScanline(const void *scanline_bytes)
virtual PixelFormat GetPixelFormat()
Returns the pixel format that need to be used by writer.
virtual ScanlineStatus ReadNextScanlineWithStatus(void **out_scanline_bytes)
ScanlineToFrameReaderAdapter(ScanlineReaderInterface *scanline_reader, MessageHandler *message_handler)
Acquires ownership of 'scanline_reader'.
virtual ScanlineStatus FinalizeWrite()
Finalizes the image once all the frames have been written.