# Dirac - A Video Codec

Created by the British Broadcasting Corporation.

pic_io.h
Go to the documentation of this file.
1/* ***** BEGIN LICENSE BLOCK *****
2*
3* $Id: pic_io.h,v 1.19 2008/06/19 10:17:17 tjdwave Exp $ $Name: Dirac_1_0_2 $
4*
5* Version: MPL 1.1/GPL 2.0/LGPL 2.1
6*
7* The contents of this file are subject to the Mozilla Public License
8* Version 1.1 (the "License"); you may not use this file except in compliance
9* with the License. You may obtain a copy of the License at
10* http://www.mozilla.org/MPL/
11*
12* Software distributed under the License is distributed on an "AS IS" basis,
13* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
14* the specific language governing rights and limitations under the License.
15*
16* The Original Code is BBC Research and Development code.
17*
18* The Initial Developer of the Original Code is the British Broadcasting
19* Corporation.
20* Portions created by the Initial Developer are Copyright (C) 2004.
21* All Rights Reserved.
22*
23* Contributor(s): Thomas Davies (Original Author),
24* Scott Robert Ladd,
25* Stuart Cunningham,
26* Tim Borer,
27* Anuradha Suraparaju
28*
29* Alternatively, the contents of this file may be used under the terms of
30* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser
31* Public License Version 2.1 (the "LGPL"), in which case the provisions of
32* the GPL or the LGPL are applicable instead of those above. If you wish to
33* allow use of your version of this file only under the terms of the either
34* the GPL or LGPL and not to allow others to use your version of this file
35* under the MPL, indicate your decision by deleting the provisions above
36* and replace them with the notice and other provisions required by the GPL
37* or LGPL. If you do not delete the provisions above, a recipient may use
38* your version of this file under the terms of any one of the MPL, the GPL
39* or the LGPL.
40* ***** END LICENSE BLOCK ***** */
41
42#ifndef _PIC_IO_H_
43#define _PIC_IO_H_
44
45#include <iostream>
46#include <fstream>
47#include <streambuf>
48
49#include <libdirac_common/common.h>
50#include <libdirac_common/picture.h>
51
52 namespace dirac
53{
54
56 //--------------------------------------//
57 //- -//
58 //-Uncompressed picture file IO wrapper-//
59 //- -//
60 //--------------------------------------//
62
63 // Stream classes for writing/reading frames of uncompressed/decoded data
64 // to stream. Streams currently supported are Memory based streams and
65 // File based streams. These classes need further restructuring.
66 // Anu - 19-11-2004
67
68 // Subclass these to provide functionality for different file formats and
69 // for streaming.
70
71
73
74
78 class StreamPicOutput
79 {
80 public:
82
87 StreamPicOutput( std::ostream* op_ptr, const SourceParams& sp);
88
90 virtual ~StreamPicOutput();
91
93 virtual bool WriteToNextFrame(const Picture& myframe) = 0;
94
96 SourceParams& GetSourceParams() {return m_sparams;}
97
98 protected:
100 SourceParams m_sparams;
102 std::ostream* m_op_pic_ptr;
103
105 StreamPicOutput();
106 private:
107
108 };
109
110 class StreamFrameOutput : public StreamPicOutput
111 {
112 public:
113
119 StreamFrameOutput( std::ostream *op_ptr, const SourceParams& sp);
120
122 virtual ~StreamFrameOutput();
123
125 bool WriteToNextFrame(const Picture& myframe);
126
127 protected:
129 bool WriteFrameComponent(const PicArray& pic_data,
130 const CompSort& cs);
131 private:
133 StreamFrameOutput();
134 };
135
136 class StreamFieldOutput : public StreamPicOutput
137 {
138 public:
140
145 StreamFieldOutput( std::ostream *op_ptr, const SourceParams& sp);
146
148 virtual ~StreamFieldOutput();
149
151 bool WriteToNextFrame(const Picture& myfield);
152
153 protected:
155 bool WriteFieldComponent(const PicArray& pic_data,
156 int field_num,
157 const CompSort& cs);
158
159 private:
161 StreamFieldOutput();
162 unsigned char *m_frame_store;
163 };
164
168 class MemoryStreamOutput
169 {
170 public:
172 MemoryStreamOutput(SourceParams &sparams, bool interlace);
173
175 ~MemoryStreamOutput();
176
178 SourceParams& GetSourceParams()
179 { return m_op_pic_str->GetSourceParams();}
180
181 StreamPicOutput *GetStream() { return m_op_pic_str; }
183 void SetMembufReference (unsigned char *buf, int buf_size);
184
185 protected:
187 MemoryStreamOutput();
189 MemoryStreamOutput(const MemoryStreamOutput&);
191 MemoryStreamOutput & operator =(const MemoryStreamOutput&);
192
193 protected:
194
196 class OutputMemoryBuffer : public std::streambuf
197 {
198 public:
200 OutputMemoryBuffer () :
201 m_op_buf(0),
202 m_op_buf_size(0),
203 m_op_idx(0)
204 {}
205
207
211 void SetMembufReference (unsigned char *buffer, int buffer_size)
212 {
213 m_op_buf = buffer;
214 m_op_buf_size = buffer_size;
215 m_op_idx = 0;
216 }
217
218 protected:
220 unsigned char *m_op_buf;
222 int m_op_buf_size;
224 int m_op_idx;
225
227 virtual int overflow (int c)
228 {
229 if ( c != EOF)
230 {
231 if (m_op_idx == m_op_buf_size)
232 return EOF;
233
234 m_op_buf[m_op_idx] = (char)c;
235 m_op_idx++;
236 }
237 return c;
238 }
239
241 virtual std::streamsize xsputn (const char *s,
242 std::streamsize num)
243 {
244 std::streamsize bytes_left = m_op_buf_size - m_op_idx;
245 std::streamsize bytes_written = bytes_left > num
246 ? num : bytes_left;
247 memcpy (&m_op_buf[m_op_idx], (unsigned char *)s,
248 bytes_written);
249 m_op_idx += bytes_written;
250 return bytes_written;
251 }
252
253 private:
255 OutputMemoryBuffer(const OutputMemoryBuffer&);
257 OutputMemoryBuffer& operator =(const OutputMemoryBuffer&);
258 };
259
260 private:
262 OutputMemoryBuffer m_membuf;
264 std::ostream* m_op_pic_ptr;
266 StreamPicOutput *m_op_pic_str;
267 };
268
272 class FileStreamOutput
273 {
274 public:
275
277
283 FileStreamOutput (const char* output_name,
284 const SourceParams& sp, bool interlace);
285
287 virtual ~FileStreamOutput ();
288
289 StreamPicOutput *GetStream() { return m_op_pic_str; }
290 private:
292 std::ostream* m_op_pic_ptr;
294 StreamPicOutput *m_op_pic_str;
295 };
296
298
302 class StreamPicInput
303 {
304 public:
305
307 StreamPicInput();
309
314 StreamPicInput(std::istream *ip_pic_ptr, const SourceParams& sparams);
315
317 virtual ~StreamPicInput();
318
320 virtual void Skip( const int n)= 0;
321
323 virtual bool ReadNextPicture(Picture& mypic) = 0;
324
326 SourceParams& GetSourceParams() const {return m_sparams;}
327
329 bool End() const ;
330
331 protected:
332
334 mutable SourceParams m_sparams;
335
337 std::istream* m_ip_pic_ptr;
338
339 };
340
341 class StreamFrameInput : public StreamPicInput
342 {
343 public:
344
346 StreamFrameInput();
348
353 StreamFrameInput(std::istream *ip_pic_ptr, const SourceParams& sparams);
354
356 virtual ~StreamFrameInput();
357
359 virtual void Skip( const int n);
360
362 virtual bool ReadNextPicture(Picture& myframe);
363
364 private:
365
367 bool ReadFrameComponent(PicArray& pic_data,const CompSort& cs);
368
369 };
370
371 class StreamFieldInput : public StreamPicInput
372 {
373 public:
374
376 StreamFieldInput();
378
383 StreamFieldInput(std::istream *ip_pic_ptr, const SourceParams& sparams);
384
386 virtual ~StreamFieldInput();
387
389 virtual void Skip( const int n);
390
392 virtual bool ReadNextPicture(Picture& myfield);
393
395 bool ReadNextFrame(Picture& field1, Picture& field2);
396
397 protected:
399 bool ReadFieldComponent(PicArray& pic_data1,
400 PicArray& pic_data2,
401 const CompSort& cs);
402
404 bool ReadFieldComponent(bool is_field1, PicArray& pic_data,
405 const CompSort& cs);
406 };
410 class MemoryStreamInput
411 {
412 public:
414
418 MemoryStreamInput(SourceParams& sparams, bool field_input);
419
421 ~MemoryStreamInput();
422
423 SourceParams& GetSourceParams ( )
424 { return m_inp_str->GetSourceParams(); }
425
427
431 void SetMembufReference (unsigned char *buf, int buf_size);
432
434 StreamPicInput *GetStream() { return m_inp_str; }
435 protected:
437 MemoryStreamInput(const MemoryStreamInput&);
439 MemoryStreamInput & operator =(const MemoryStreamInput&);
440
441 protected:
443 class InputMemoryBuffer : public std::streambuf
444 {
445 public:
447 InputMemoryBuffer() : m_buffer(0), m_buffer_size(0)
448 {
449 setg ((char *)m_buffer, (char *)m_buffer, (char *)m_buffer);
450 }
451
453 ~InputMemoryBuffer(){}
454
456
460 void SetMembufReference (unsigned char *buffer, int buffer_size)
461 {
462 m_buffer = buffer;
463 m_buffer_size = buffer_size;
464
465 setg ((char *)m_buffer, (char *)m_buffer,
466 (char *)(m_buffer + buffer_size));
467 }
468
469 private:
471 InputMemoryBuffer (const InputMemoryBuffer& inbuf);
473 InputMemoryBuffer& operator = (const InputMemoryBuffer& inbuf);
474
476 unsigned char *m_buffer;
478 int m_buffer_size;
479 };
480
481 private:
483 InputMemoryBuffer m_membuf;
484
486 StreamPicInput *m_inp_str;
487
489 std::istream* m_ip_pic_ptr;
490 };
491
493
496 class FileStreamInput
497 {
498 public:
499
501
507 FileStreamInput (const char* input_name, const SourceParams &sparams, bool interlace);
508
510 virtual ~FileStreamInput ();
511
512 SourceParams& GetSourceParams ( )
513 { return m_inp_str->GetSourceParams(); }
514
516 StreamPicInput *GetStream() { return m_inp_str; }
517
518 private:
519 StreamPicInput *m_inp_str;
520
522 std::istream* m_ip_pic_ptr;
523
524 };
525
526} // namespace dirac
527
528#endif
picture.h
common.h
dirac
Definition of class SequenceHeaderByteIO.
Definition: accessunit_byteio.h:52
dirac::CompSort
CompSort
Types of picture component.
Definition: common.h:87
dirac::SourceParams
Parameters relating to the source material being encoded/decoded.
Definition: common.h:289
dirac::PicArray
A class for picture component data.
Definition: common.h:719
dirac::StreamPicOutput
Class for outputting pictures.
Definition: pic_io.h:79
dirac::StreamPicOutput::StreamPicOutput
StreamPicOutput(std::ostream *op_ptr, const SourceParams &sp)
Constructor.
dirac::StreamPicOutput::StreamPicOutput
StreamPicOutput()
Body-less default Constructor.
dirac::StreamPicOutput::m_sparams
SourceParams m_sparams
Source parameters.
Definition: pic_io.h:100
dirac::StreamPicOutput::m_op_pic_ptr
std::ostream * m_op_pic_ptr
Output stream.
Definition: pic_io.h:102
dirac::StreamPicOutput::~StreamPicOutput
virtual ~StreamPicOutput()
virtual Destructor
dirac::StreamPicOutput::GetSourceParams
SourceParams & GetSourceParams()
Get the source parameters.
Definition: pic_io.h:96
dirac::StreamPicOutput::WriteToNextFrame
virtual bool WriteToNextFrame(const Picture &myframe)=0
Write a picture to the next frame to be output.
dirac::StreamFrameOutput
Definition: pic_io.h:111
dirac::StreamFrameOutput::StreamFrameOutput
StreamFrameOutput(std::ostream *op_ptr, const SourceParams &sp)
dirac::StreamFrameOutput::StreamFrameOutput
StreamFrameOutput()
Body-less Default Constructor.
dirac::StreamFrameOutput::WriteToNextFrame
bool WriteToNextFrame(const Picture &myframe)
Write the next frame to the output.
dirac::StreamFrameOutput::WriteFrameComponent
bool WriteFrameComponent(const PicArray &pic_data, const CompSort &cs)
Write a frame component to file.
dirac::StreamFrameOutput::~StreamFrameOutput
virtual ~StreamFrameOutput()
virtual Destructor
dirac::StreamFieldOutput
Definition: pic_io.h:137
dirac::StreamFieldOutput::StreamFieldOutput
StreamFieldOutput()
Body-less Default Constructor.
dirac::StreamFieldOutput::WriteFieldComponent
bool WriteFieldComponent(const PicArray &pic_data, int field_num, const CompSort &cs)
Write a field component to file.
dirac::StreamFieldOutput::WriteToNextFrame
bool WriteToNextFrame(const Picture &myfield)
Write a field to the next frame to be output.
dirac::StreamFieldOutput::m_frame_store
unsigned char * m_frame_store
Definition: pic_io.h:162
dirac::StreamFieldOutput::StreamFieldOutput
StreamFieldOutput(std::ostream *op_ptr, const SourceParams &sp)
Constructor.
dirac::StreamFieldOutput::~StreamFieldOutput
virtual ~StreamFieldOutput()
virtual Destructor
dirac::MemoryStreamOutput
Definition: pic_io.h:169
dirac::MemoryStreamOutput::GetSourceParams
SourceParams & GetSourceParams()
Get source parameters.
Definition: pic_io.h:178
dirac::MemoryStreamOutput::MemoryStreamOutput
MemoryStreamOutput()
Body-less default Constructor.
dirac::MemoryStreamOutput::~MemoryStreamOutput
~MemoryStreamOutput()
Destructor.
dirac::MemoryStreamOutput::m_op_pic_str
StreamPicOutput * m_op_pic_str
Pic output Stream.
Definition: pic_io.h:266
dirac::MemoryStreamOutput::MemoryStreamOutput
MemoryStreamOutput(const MemoryStreamOutput &)
Body-less copy constructor.
dirac::MemoryStreamOutput::m_membuf
OutputMemoryBuffer m_membuf
Output stream Memory buffer.
Definition: pic_io.h:262
dirac::MemoryStreamOutput::operator=
MemoryStreamOutput & operator=(const MemoryStreamOutput &)
Body-less assignment operator.
dirac::MemoryStreamOutput::MemoryStreamOutput
MemoryStreamOutput(SourceParams &sparams, bool interlace)
Constructor.
dirac::MemoryStreamOutput::GetStream
StreamPicOutput * GetStream()
Definition: pic_io.h:181
dirac::MemoryStreamOutput::SetMembufReference
void SetMembufReference(unsigned char *buf, int buf_size)
Set the memory buffer to write the data to.
dirac::MemoryStreamOutput::m_op_pic_ptr
std::ostream * m_op_pic_ptr
Physical Output stream.
Definition: pic_io.h:264
dirac::MemoryStreamOutput::OutputMemoryBuffer
local memory buffer
Definition: pic_io.h:197
dirac::MemoryStreamOutput::OutputMemoryBuffer::m_op_buf_size
int m_op_buf_size
Memory buffer size.
Definition: pic_io.h:222
dirac::MemoryStreamOutput::OutputMemoryBuffer::m_op_buf
unsigned char * m_op_buf
Memory buffer to write data to.
Definition: pic_io.h:220
dirac::MemoryStreamOutput::OutputMemoryBuffer::xsputn
virtual std::streamsize xsputn(const char *s, std::streamsize num)
xsputn method to write one multiple chars at a time to buffer
Definition: pic_io.h:241
dirac::MemoryStreamOutput::OutputMemoryBuffer::OutputMemoryBuffer
OutputMemoryBuffer(const OutputMemoryBuffer &)
Body-less copy constructor.
dirac::MemoryStreamOutput::OutputMemoryBuffer::m_op_idx
int m_op_idx
Index of first available byte in buffer.
Definition: pic_io.h:224
dirac::MemoryStreamOutput::OutputMemoryBuffer::overflow
virtual int overflow(int c)
Write Overflow method to write one char at a time.
Definition: pic_io.h:227
dirac::MemoryStreamOutput::OutputMemoryBuffer::operator=
OutputMemoryBuffer & operator=(const OutputMemoryBuffer &)
Body-less assignment operator.
dirac::MemoryStreamOutput::OutputMemoryBuffer::SetMembufReference
void SetMembufReference(unsigned char *buffer, int buffer_size)
Set the buffer variables.
Definition: pic_io.h:211
dirac::MemoryStreamOutput::OutputMemoryBuffer::OutputMemoryBuffer
OutputMemoryBuffer()
Memory buffer constructor.
Definition: pic_io.h:200
dirac::FileStreamOutput
Definition: pic_io.h:273
dirac::FileStreamOutput::~FileStreamOutput
virtual ~FileStreamOutput()
Destructor.
dirac::FileStreamOutput::FileStreamOutput
FileStreamOutput(const char *output_name, const SourceParams &sp, bool interlace)
Constructor.
dirac::FileStreamOutput::m_op_pic_str
StreamPicOutput * m_op_pic_str
Pic output Stream.
Definition: pic_io.h:294
dirac::FileStreamOutput::m_op_pic_ptr
std::ostream * m_op_pic_ptr
Physical Output stream.
Definition: pic_io.h:292
dirac::FileStreamOutput::GetStream
StreamPicOutput * GetStream()
Definition: pic_io.h:289
dirac::StreamPicInput
Picture input class.
Definition: pic_io.h:303
dirac::StreamPicInput::ReadNextPicture
virtual bool ReadNextPicture(Picture &mypic)=0
Read the next picture frame/field from the file.
dirac::StreamPicInput::StreamPicInput
StreamPicInput(std::istream *ip_pic_ptr, const SourceParams &sparams)
Constructor.
dirac::StreamPicInput::~StreamPicInput
virtual ~StreamPicInput()
Destructor.
dirac::StreamPicInput::GetSourceParams
SourceParams & GetSourceParams() const
Get the source parameters.
Definition: pic_io.h:326
dirac::StreamPicInput::End
bool End() const
Returns true if we're at the end of the input, false otherwise.
dirac::StreamPicInput::Skip
virtual void Skip(const int n)=0
Skip n frames of input.
dirac::StreamPicInput::StreamPicInput
StreamPicInput()
Default Constructor.
dirac::StreamPicInput::m_ip_pic_ptr
std::istream * m_ip_pic_ptr
Input stream.
Definition: pic_io.h:337
dirac::StreamPicInput::m_sparams
SourceParams m_sparams
Source parameters.
Definition: pic_io.h:334
dirac::StreamFrameInput
Definition: pic_io.h:342
dirac::StreamFrameInput::StreamFrameInput
StreamFrameInput()
Default Constructor.
dirac::StreamFrameInput::ReadFrameComponent
bool ReadFrameComponent(PicArray &pic_data, const CompSort &cs)
Read a Frame component from the file.
dirac::StreamFrameInput::Skip
virtual void Skip(const int n)
Skip n frames of input.
dirac::StreamFrameInput::ReadNextPicture
virtual bool ReadNextPicture(Picture &myframe)
Read the next frame from the file.
dirac::StreamFrameInput::~StreamFrameInput
virtual ~StreamFrameInput()
Destructor.
dirac::StreamFrameInput::StreamFrameInput
StreamFrameInput(std::istream *ip_pic_ptr, const SourceParams &sparams)
Constructor.
dirac::StreamFieldInput
Definition: pic_io.h:372
dirac::StreamFieldInput::ReadNextPicture
virtual bool ReadNextPicture(Picture &myfield)
Read the next field from the file.
dirac::StreamFieldInput::Skip
virtual void Skip(const int n)
Skip n frames of input.
dirac::StreamFieldInput::~StreamFieldInput
virtual ~StreamFieldInput()
Destructor.
dirac::StreamFieldInput::StreamFieldInput
StreamFieldInput()
Default Constructor.
dirac::StreamFieldInput::ReadFieldComponent
bool ReadFieldComponent(PicArray &pic_data1, PicArray &pic_data2, const CompSort &cs)
Read both Field components from the file.
dirac::StreamFieldInput::ReadNextFrame
bool ReadNextFrame(Picture &field1, Picture &field2)
Read the next frame from the file.
dirac::StreamFieldInput::StreamFieldInput
StreamFieldInput(std::istream *ip_pic_ptr, const SourceParams &sparams)
Constructor.
dirac::StreamFieldInput::ReadFieldComponent
bool ReadFieldComponent(bool is_field1, PicArray &pic_data, const CompSort &cs)
Read one Field component from the file.
dirac::MemoryStreamInput
Definition: pic_io.h:411
dirac::MemoryStreamInput::MemoryStreamInput
MemoryStreamInput(SourceParams &sparams, bool field_input)
Constructor.
dirac::MemoryStreamInput::m_inp_str
StreamPicInput * m_inp_str
Input Stream Object.
Definition: pic_io.h:486
dirac::MemoryStreamInput::m_ip_pic_ptr
std::istream * m_ip_pic_ptr
Input stream.
Definition: pic_io.h:489
dirac::MemoryStreamInput::SetMembufReference
void SetMembufReference(unsigned char *buf, int buf_size)
Set Memory buffer.
dirac::MemoryStreamInput::~MemoryStreamInput
~MemoryStreamInput()
Destructor.
dirac::MemoryStreamInput::GetStream
StreamPicInput * GetStream()
Return the input stream.
Definition: pic_io.h:434
dirac::MemoryStreamInput::operator=
MemoryStreamInput & operator=(const MemoryStreamInput &)
Body-less assignment operator.
dirac::MemoryStreamInput::MemoryStreamInput
MemoryStreamInput(const MemoryStreamInput &)
Body-less copy constructor.
dirac::MemoryStreamInput::m_membuf
InputMemoryBuffer m_membuf
Input stream buffer.
Definition: pic_io.h:483
dirac::MemoryStreamInput::GetSourceParams
SourceParams & GetSourceParams()
Definition: pic_io.h:423
dirac::MemoryStreamInput::InputMemoryBuffer
Class that defines the Input Stream Memory Buffer.
Definition: pic_io.h:444
dirac::MemoryStreamInput::InputMemoryBuffer::operator=
InputMemoryBuffer & operator=(const InputMemoryBuffer &inbuf)
Body-less assignment operator.
dirac::MemoryStreamInput::InputMemoryBuffer::m_buffer_size
int m_buffer_size
Input memory buffer size.
Definition: pic_io.h:478
dirac::MemoryStreamInput::InputMemoryBuffer::InputMemoryBuffer
InputMemoryBuffer(const InputMemoryBuffer &inbuf)
Body-less copy constructor.
dirac::MemoryStreamInput::InputMemoryBuffer::~InputMemoryBuffer
~InputMemoryBuffer()
Destructor.
Definition: pic_io.h:453
dirac::MemoryStreamInput::InputMemoryBuffer::InputMemoryBuffer
InputMemoryBuffer()
Constructor.
Definition: pic_io.h:447
dirac::MemoryStreamInput::InputMemoryBuffer::m_buffer
unsigned char * m_buffer
Input memory buffer.
Definition: pic_io.h:476
dirac::MemoryStreamInput::InputMemoryBuffer::SetMembufReference
void SetMembufReference(unsigned char *buffer, int buffer_size)
Set Input Memory buffer variables.
Definition: pic_io.h:460
dirac::FileStreamInput
Picture input class.
Definition: pic_io.h:497
dirac::FileStreamInput::FileStreamInput
FileStreamInput(const char *input_name, const SourceParams &sparams, bool interlace)
Constructor.
dirac::FileStreamInput::GetStream
StreamPicInput * GetStream()
Return the input stream.
Definition: pic_io.h:516
dirac::FileStreamInput::m_inp_str
StreamPicInput * m_inp_str
Definition: pic_io.h:519
dirac::FileStreamInput::GetSourceParams
SourceParams & GetSourceParams()
Definition: pic_io.h:512
dirac::FileStreamInput::~FileStreamInput
virtual ~FileStreamInput()
Destructor.
dirac::FileStreamInput::m_ip_pic_ptr
std::istream * m_ip_pic_ptr
Input stream.
Definition: pic_io.h:522
dirac::Picture
A class for encapsulating all the data relating to a picture.
Definition: picture.h:52

© 2004 British Broadcasting Corporation. Dirac code licensed under the Mozilla Public License (MPL) Version 1.1.
HTML documentation generated by Dimitri van Heesch's excellent Doxygen tool.