MJPEG AVI Library Developer's Guide

Similar documents
NVJPEG. DA _v0.2.0 October nvjpeg Libary Guide

ADSP EZ-ICE Emulator User s Guide (For Use with VisualDSP++ Release 2.0 or Higher)

TriMedia Motion JPEG Decoder (VdecMjpeg) API 1

OptimiData. JPEG2000 Software Development Kit for C/C++ Reference Manual. Version 1.6. from

Short Notes of CS201

CS201 - Introduction to Programming Glossary By

NVJPEG. DA _v0.1.4 August nvjpeg Libary Guide

Intel Stress Bitstreams and Encoder (Intel SBE) 2017 AVS2 Release Notes (Version 2.3)

ICE-100B Emulator User Guide

Section 2 Introduction to VisualDSP++

Apex-ICE Universal JTAG Emulator Hardware and Software Installation Guide

Apex-ICE Universal Emulator Hardware and Software Installation Guide

User s Manual. PCIe-DIO05 Users Manual (Rev 1.1)

TriMedia Motion JPEG Encoder (VencMjpeg) API 1

Rapid Development of a Blackfin-based Video Application

GPU Offline Shader Compiler. Mali. User Guide. Version: 2.2. Copyright 2009 ARM. All rights reserved. ARM DUI 0513A (ID101409)

LogiCORE IP Image Noise Reduction v2.0 Bit Accurate C Model

W4.0 Getting Started Guide

LogiCORE IP 3GPP LTE Turbo Encoder v1.0 Bit-Accurate C Model. 3GPP LTE Turbo. [optional] UG490 (v1.0) April 25, 2008 [optional]

Name :. Roll No. :... Invigilator s Signature : INTRODUCTION TO PROGRAMMING. Time Allotted : 3 Hours Full Marks : 70

W5.0 Licensing Guide. Revision 1.0, August 2007 Part Number: Analog Devices, Inc. One Technology Way Norwood, Mass.

SigmaStudio Release Notes

The World Leader in High Performance Signal Processing Solutions. Development Tools.

3COM0271 Computer Network Protocols & Architectures A

PCIe-FRM16. User s Manual

GO-GLOBAL. Client Process Manager API. Version 4.8.2

W4.5 Getting Started Guide

ICE-1000/ICE-2000 Emulator User s Guide

GPU Shader Library. Mali. User Guide. Version: 1.0. Copyright 2009 ARM. All rights reserved. ARM DUI 0510A (ID101409)

USB BF70x Bulk Library v.1.1 Users Guide Users Guide Revision 1.1. For Use With Analog Devices ADSP-BF70x Series Processors. Closed Loop Design, LLC

As of October 1, 1998, our address is:

PCI-DIO02. User s Manual

ForwardT Software SoftLab-NSK. Video Codecs. Properties and Settings. Version current as of 26/06/2015. User s Guide. SoftLab-NSK

Tivoli SecureWay Policy Director Authorization ADK. Developer Reference. Version 3.8

Arm Design Simulation Model

Design Simulation Model ARM. User Guide. for SystemC. Copyright 2016 ARM. All rights reserved. ARM ARM DUI 1031B (ID111116)

Release Notes for VisualDSP

B.V. Patel Institute of Business Management, Computer & Information Technology, Uka Tarsadia University

The following revision history lists the anomaly list revisions and major changes for each anomaly list revision.

lwip for CrossCore Embedded Studio User s Guide

Dialogic Multimedia API

Program Block Editor and Compiler (PBEC)

P.G.TRB - COMPUTER SCIENCE. c) data processing language d) none of the above

GLExpert NVIDIA Performance Toolkit

What the CPU Sees Basic Flow Control Conditional Flow Control Structured Flow Control Functions and Scope. C Flow Control.

Introduction to VisualAudio

Contents. Chapter 1 Overview of the JavaScript C Engine...1. Chapter 2 JavaScript API Reference...23

Computer Programming C++ (wg) CCOs

ISO/IEC INTERNATIONAL STANDARD. Information technology JPEG 2000 image coding system Part 3: Motion JPEG 2000

Blackfin Online Learning & Development

Engineer-to-Engineer Note

New York University Computer Science Department Courant Institute of Mathematical Sciences

Problem Solving and 'C' Programming

Intel Stress Bitstreams and Encoder (Intel SBE) HEVC Getting Started

Enhanced Serial Peripheral Interface (espi)

UM1641 User manual. Sampling rate conversion SRC236 library software expansion for STM32Cube. Introduction

CLD BF70x CDC Library v.1.3 Users Guide Users Guide Revision 1.3. For Use With Analog Devices ADSP-BF70x Series Processors. Closed Loop Design, LLC

Express Card-FRM11. User s Manual. ecard-frm11 User s Manual (Rev 2.1)

Intel Active Management Technology Release 1.0 Host Interface Design Guide

PCI-FRM11. User s Manual. PCI-FRM11 User s Manual (Rev 1.1)

NVIDIA CAPTURE SDK 7.1 (WINDOWS)

Multimedia for Host Media Processing Demo

As of October 1, 1998, our address is:

reclaim disk space by shrinking files

W 3.5 Loader Manual for 16-Bit Processors

Secure software guidelines for ARMv8-M. for ARMv8-M. Version 0.1. Version 2.0. Copyright 2017 ARM Limited or its affiliates. All rights reserved.

Engineer-to-Engineer Note

libtheora Reference Manual

User Guide. GLExpert NVIDIA Performance Toolkit

PCI-AIO02. User s Manual

Network Working Group. November Encoding Long Options in the Dynamic Host Configuration Protocol (DHCPv4)

Storing Data: Disks and Files

Important Upgrade Information

ISO/IEC INTERNATIONAL STANDARD. Information technology JPEG 2000 image coding system: Motion JPEG 2000

Bootloader Firmware Update Protocol and Procedure

INDEX. Figure I-0. Listing I-0. Table I-0. Symbols.DIRECTIVE (see Assembler directives)? preprocessor operator 3-34

Offline Shader Compiler. Mali. User Guide. Version: 3.0. Copyright ARM. All rights reserved. ARM DUI 0513B (ID032912)

MATLAB 7 Getting Started Guide

BlackBerry Software Development Kit Version 2.5. System Utilities API Reference Guide

[MS-MCI]: Microsoft ZIP (MSZIP) Compression and Decompression Data Structure

GPU LIBRARY ADVISOR. DA _v8.0 September Application Note

TIBCO iprocess Workspace Plug-ins Installation. Software Release 11.2 September 2009

[MS-RTPRADEX]: RTP Payload for Redundant Audio Data Extensions. Intellectual Property Rights Notice for Open Specifications Documentation

Advanced Design System ISS Cosimulation

C:\Program Files\Analog Devices\VisualDSP++>elfdump. Table B-1. ELF File Dumper Command-Line Option Switches. Print the archive symbol table.

TIBCO ActiveMatrix BusinessWorks Plug-in for WebSphere MQ Installation

SEGGER J-Scope. User Guide. Document: UM08028 Software Version: 5.10 Revision: 0 Date: November 26, 2015

AN1369 APPLICATION NOTE

Quick Reference for shmdefine

L9: Storage Manager Physical Data Organization

PCI-AIO01. User s Manual

Getting Started. NVIDIA CUDA C Installation and Verification on Mac OS X

NSIGHT ECLIPSE PLUGINS INSTALLATION GUIDE

USB BF70x Audio 1.0 Library v.1.2 Users Guide Users Guide Revision 1.3. For Use With Analog Devices ADSP-BF70x Series Processors

KEPLER COMPATIBILITY GUIDE FOR CUDA APPLICATIONS

CSTA Gatekeeper Installation and Configuration Guide

Tizen/Artik IoT Lecture Chapter 3. JerryScript Parser & VM

GRID SOFTWARE MANAGEMENT SDK

Media Formats. Sound. Image. Video. WAV (uncompressed, PCM) MIDI. BMP XML dia MPEG

CA Oblicore Guarantee 7.0 Service Pack 1 High Availability Upgrade Guide

Transcription:

DEVIM1-002-D October 2005 Analog Devices Inc. www.analog.com

Table of Contents 1. Introduction...6 1.1. Scope...6 1.2. Target platform...6 1.3. Organisation of this Guide...6 1.4. Version Information...6 1.5. System Requirements...6 1.6. References...6 1.7. Additional Information...7 2. Specifications...7 2.1. Input formats...7 2.2. Output formats...7 2.3. MIPS Performance...7 2.4. Memory Requirements...7 3. Usage...8 3.1. Tools...8 3.2. Software Integration...8 3.2.1. Encoding...8 3.2.1.1. JPEG encoder library...8 3.2.1.2. MJPEG AVI encoder library...9 3.2.1.2.1. Temporary storage...9 3.2.2. Decoding...9 3.2.2.1. JPEG decoder library...9 3.2.2.2. MJPEG AVI decoding...9 3.3. Programming Example...9 3.3.1. MJPEG AVI Encoder...9 3.3.2. MJPEG AVI Decoder...11 4. Programmer s Reference...12 4.1. MJPEG AVI Encoder Library...13 4.1.1. MJPEG_AVI_OpenFileWrite...13 4.1.2. MJPEG_AVI_CloseFileWrite...13 4.1.3. MJPEG_AVI_OpenStreamWrite...13 4.1.4. MJPEG_AVI_CloseStreamWrite...14 4.1.5. MJPEG_AVI_WriteStream...14 4.2. MJPEG AVI Decoder Library...14 4.2.1. MJPEG_AVI_OpenFileRead...14 DEVIM1-002-D Proprietary and Confidential Page 2 of 17

4.2.2. MJPEG_AVI_CloseFileRead...15 4.2.3. MJPEG_AVI_OpenStreamRead...15 4.2.4. MJPEG_AVI_CloseStreamRead...16 4.2.5. MJPEG_AVI_RewindToFirstFrame...16 4.2.6. MJPEG_AVI_ReadNextFrame...17 List of Tables Table 1: Tool versions...6 Table 2: Memory Requirements of MJPEG AVI libraries...8 DEVIM1-002-D Proprietary and Confidential Page 3 of 17

DEVIM1-002-D Proprietary and Confidential Page 4 of 17

Copyright Information 2005 Analog Devices, Inc., ALL RIGHTS RESERVED. This document may not be reproduced in any form without prior, express written consent from Analog Devices, Inc. Disclaimer Analog Devices, Inc. reserves the right to change this product without prior notice. Information furnished by Analog Devices is believed to be accurate and reliable. However, no responsibility is assumed by Analog Devices for its use; nor for any infringement of patents or other rights of third parties which may result from its use. No license is granted by implication or otherwise under the patent rights of Analog Devices, Inc. Trademark and Service Mark Notice The Analog Devices logo, SHARC, VisualDSP++, Blackfin, and EZKIT Lite are registered trademarks of Analog Devices, Inc. VisualAudio is a trademark of Analog Devices, Inc. All other brand and product names are trademarks or service marks of their respective owners. DEVIM1-002-D Proprietary and Confidential Page 5 of 17

1. Introduction This document describes how the developer can use the MJPEG AVI Library in an application. 1.1. Scope This guide is intended for C-language developers proficient in the application of the Analog Devices Blackfin family of processors and related software tools. It is assumed that the reader is familiar with all aspects of these processors. 1.2. Target platform The MJPEG AVI library was designed for the Analog Devices Blackfin processors. 1.3. Organisation of this Guide Information supplied in this guide is organised in the following way. Section 2 provides the specifications of the implemented MJPEG AVI library. In Section 3, notes on how to use and integrate the library are given. Finally, Section 3.3 describes the high-level software structure of the library. 1.4. Version Information This document refers to the following software versions: MJPEG AVI Library: ADI Version 4.0.0. Any information that accompanies the software libraries (in the form of 'readme' files, etc.) should be assumed to supersede the information contained in this document. 1.5. System Requirements The MJPEG AVI Encoder and Decoder library modules were created and tested with versions of tools listed in Table 1. To ensure the maximum level of compatibility, please use these versions of the tools (listed tools correspond to the September 2005 update for VDSP++ 4.0). Tool Name Tool Description Tool Version ccblkfn C/C++ compiler 7.1.3.6 easmblkfn BlackFin assembler 2.6.9.8 elfar ELF Librarian/Archive Utility 4.5.1.3 linker Linker 3.5.8.1 Table 1: Tool versions 1.6. References [1] ITU-T, Information Technology- Digital Compression and Coding of Continuous-Tone Still Images- Requirements and Guidelines, Recommendation T.81 (09/92), September 1992. [2] Analog Devices Inc., JPEG Encoder Library Developer's Guide, DEVIMG-002, October 2005. [3] Analog Devices Inc., JPEG Decoder Library Developer's Guide, DEVIMG-001, October 2005. DEVIM1-002-D Proprietary and Confidential Page 6 of 17

1.7. Additional Information For more information on the latest ADI processors, silicon errata, code examples, development tools, system services and devices drivers, technical support and any other additional information, please visit our website at www.analog.com/processors. 2. Specifications The MJPEG AVI Library implements motion picture compression and decompression to/from the AVI format following standard [1] for individual image frames. The JPEG encoder library must be installed and working correctly before using the MJPEG AVI encoder functions. Likewise, the JPEG decoder library must be installed and working correctly before using the MJPEG AVI decoding functions. See the references for more information about the JPEG encoder and decoder libraries. 2.1. Input formats Encoder: A single input format is used for an entire MJPEG AVI stream. This format can be one of YUV4:2:2, YUV4:2:0, or Y (YUV4:0:0, i.e. monochrome). In all formats, the components are not interleaved. Refer to [2] for more information about available JPEG input formats. Input to the MJPEG AVI encoder consists of concatenated input image frames. Decoder: The MJPEG AVI Decoder takes as input an AVI stream file. All reading from the stream file occurs through the file system (i.e. calls to stdio.h) so a suitable file system is required for decoder operation. 2.2. Output formats Encoder: The MJPEG AVI Encoder creates an AVI file, composed of individual JPEG-encoded frames. The sequential (baseline) JPEG mode is recommended, where each image component is encoded in a single left-to-right, top-to-bottom raster scan. All writing to the stream file occurs through the file system (i.e. calls to stdio.h) so a suitable file system is required for operation. Decoder: The MJPEG AVI Decoder returns the bitstream corresponding to each frame in the specified memory buffer, which then needs to be decoded using a JPEG Decoder and subsequently the decoded frame may be written to a file to create a concatenated image file (raw video sequence), or sent to a video display. 2.3. MIPS Performance A complete specification is not currently available. There are many factors that affect performance, some of which are data dependent. The MIPS overhead is low however, as there is little numerical processing performed in the MJPEG AVI module. The MIPS requirements for the JPEG Encoder and Decoder libraries are described in [2][3]. 2.4. Memory Requirements This section covers memory requirements for the MJPEG AVI library. The memory requirements for the JPEG Encoder and Decoder libraries are described elsewhere [2][3]. DEVIM1-002-D Proprietary and Confidential Page 7 of 17

The memory requirements and memory section names for the MJPEG libraries are shown in Table 2. Encoding Mode Encoder Decoder Program Memory Data Memory (kb) (kb) (MJPEGENC_P0) 1.2 0.4 (MJPEGDEC_P0) 2.1 0.1 Heap Maximum (kb) 0.2+0.016N 0.2 Table 2: Memory Requirements of MJPEG AVI libraries Here, N represents the number of frames written to the AVI file. Data memory section names MJPEGENC_D0 and MJPEGDEC_D0, data1, constdata and bsz are used by the MJPEG AVI libraries. 3. Usage 3.1. Tools The VisualDSP++ 4.0 integrated development environment for Blackfin is used to build the library and example applications on a Windows PC. The required versions of the tools in this environment are stated in Section 1.4 of this document. 3.2. Software Integration This section details how to integrate the MJPEG functionality into a test application ( the application ). 3.2.1. Encoding 3.2.1.1. JPEG encoder library The application must link against the JPEG encoder library, so the library file jpeg_enc_lib_xxxx.dlb must be included in the application makefile (where XXXX identifies the library version). If the VisualDSP graphical interface is used, this file can be added to the project under Project Options Link Additional Options by: typing in the full filename of the library, specifying the path that points to this library under Project Options Link Search Directories, and specifying the path that points to the library header files under Project Options Compile Preprocessor Additional Include Directories. Alternatively, one can drag the library file from an open Windows Explorer window to the Project Window in VisualDSP++. The following JPEG header files must be #included in the application: jpeg_api_encoder.h and the JPEG export directory must be specified as an included in the application project. DEVIM1-002-D Proprietary and Confidential Page 8 of 17

3.2.1.2. MJPEG AVI encoder library The application must link against the MJPEG AVI encoder library file mjpeg_enc_lib_xxxx.dlb, following a similar procedure to that in Section 3.2.1.1 above. The following header files must be #included into the application: MJPEG_AVI_FileWriter.h and the MJPEG AVI export directory must be specified as an included in the application project. The MJPEG AVI Encoder is dependent on the JPEG Encoder library. JPEG header file JPEG_api_common.h is #included by MJPEG_AVI_FileWriter.h. 3.2.1.2.1. Temporary storage The MJPEG AVI Encoder library creates a temporary file in the current working directory, called AVIWRITE_TEMP.tmp. This file may be deleted after the encoding operation concludes. 3.2.2. Decoding 3.2.2.1. JPEG decoder library The application must link against the JPEG decoder library, so the library file jpeg_dec_lib_xxxx.dlb must be included in the application makefile, following a similar procedure to that in Section 3.2.1.1 above. The following JPEG header files must be #included in the application: jpeg_api_decoder.h and the JPEG export directory must be specified as an included in the application project. 3.2.2.2. MJPEG AVI decoding The application must link against the MJPEG AVI decoder library file mjpeg_dec_lib_xxxx.dlb, following a similar procedure to that in Section 3.2.1.1 above. The following header files must be #included into the application: MJPEG_AVI_FileReader.h and the MJPEG export directory must be specified as an included in the application project. The MJPEG AVI Decoder is dependent on the JPEG Decoder library. JPEG header file JPEG_api_common.h is #included by MJPEG_AVI_FileReader.h. 3.3. Programming Example 3.3.1. MJPEG AVI Encoder The simplest method to encode an MJPEG AVI motion picture is to call the library functions in the following order: i. Create an instance of the JPEG encoder. See Reference [2] for information about instantiating the JPEG encoder. ii. Call MJPEG_AVI_OpenFileWrite to create the output AVI file iii. iv. Call MJPEG_AVI_OpenStreamWrite to create the output stream While input data is available, call JPEG_EncodeImage to encode each frame, and write the coded frame to the output file by calling MJPEG_AVI_WriteStream DEVIM1-002-D Proprietary and Confidential Page 9 of 17

v. Close the stream and file with MJPEG_AVI_CloseStreamWrite and MJPEG_AVI_CloseFileWrite respectively The following code example uses these functions to encode a sample MJPEG AVI input stream. See the respective entries in the JPEG Encoder Programmer s Reference [2] for information about the JPEG functions called here. /* SETUP JPEG ENCODER */ /* Configure the JPEG Encoder to suit input frames and output parameters */ JPEG_Param_CONFIG(&lImageParam, JPEG_MAX_X_DIMENSION, lmaxxdimn); JPEG_Param_CONFIG(&lImageParam, JPEG_MAX_Y_DIMENSION, lmaxydimn); JPEG_Param_CONFIG(&lImageParam, JPEG_IMAGEFORMAT, linterleaveformat); JPEG_Param_CONFIG(&lImageParam, JPEG_QUALITYFACTOR, lqualityfactor); JPEG_Param_CONFIG(&lImageParam, JPEG_ENCODINGMODE, SEQUENTIAL); JPEG_Param_CONFIG(&lImageParam, JPEG_THRESHOLD, 0); /* Allocate Input and Output Buffers */ JPEG_Param_CONFIG(&lImageParam, JPEG_POINTER_INPUT, (int)lframebuffer); JPEG_Param_CONFIG(&lImageParam, JPEG_POINTER_OUTPUT, (int)lstreambuffer); /* Create Instance of JPEG Encoder */ ljpegenc = JPEG_Encoder_NEW(&lImageParam); /* SETUP MJPEG ENCODER */ /* Create the AVI output file, with the required file */ lresult = MJPEG_AVI_OpenFileWrite(&lStreamFileOutHandle, lstreamfileoutname, &limageparam, FrameRate); /* Create the stream */ lresult = MJPEG_AVI_OpenStreamWrite(lStreamFileOutHandle, &lstreamhandle, &lstreaminfo); /* ENCODE EACH FRAME */ /* Main loop for each frame */ fprintf(testreportfile, "Main loop\n"); /*... Read frame from file into lframebuffer here...*/ while (isinputdataavailable) { /* Encode the image frame */ lresult = JPEG_EncodeImage(lJpegEnc, &NumBytes); /* Write the encoded frame to the stream */ lresult = MJPEG_AVI_WriteStream(lStreamHandle, lstreambuffer, NumBytes, 0); /*... Read the next frame from file into lframebuffer here...*/ } /* end while main loop */ /************************************/ /* FINALISE AND DESTROY ENCODER */ /************************************/ /* Close the AVI stream*/ lresult = MJPEG_AVI_CloseStreamWrite(lStreamHandle); /* Close the output file*/ lresult = MJPEG_AVI_CloseFileWrite(lStreamFileOutHandle); DEVIM1-002-D Proprietary and Confidential Page 10 of 17

/* Free and destroy used resources */ JPEG_Encoder_DELETE(lJpegEnc); 3.3.2. MJPEG AVI Decoder The simplest method to decode an MJPEG AVI stream is to call the library functions in the following order: i. Call MJPEG_AVI_OpenFileRead to open the input AVI file ii. iii. iv. Call MJPEG_AVI_OpenStreamRead to open the input stream and to read the stream header Call MJPEG_AVI_RewindToFirstFrame to move file pointer to the start of the first frame Call JPEG_MemAlloc_NEW to allocate JPEG decoder input buffer v. Call MJPEG_AVI_ReadNextFrame to read the first frame vi. vii. viii. ix. Call JPEG_Param_CONFIG to configure JPEG_POINTER_INPUT, JPEG_POINTER_OUTPUT Call JPEG_Decoder_NEW to create decoder instance. See Reference [3] for information about instantiating the JPEG decoder. If all JPEG parameters are known, then the JPEG Decoder can be set up directly. Otherwise, if decoding an unknown MJPEG AVI, then the application needs to use information contained within the stream (see next step). Call JPEG_ProcessHeader to process the first frame of JPEG header Call MJPEG_AVI_RewindToFirstFrame to move file pointer to the start of the first frame again x. For each frame in the MJPEG AVI stream, call MJPEG_AVI_ReadNextFrame to retrieve the image frame from the stream before calling JPEG_DecodeImage to decode it. xi. xii. Call MJPEG_AVI_CloseStreamRead and MJPEG_AVI_CloseFileRead to close the AVI stream and input file, respectively Destroy the instance of the JPEG decoder. See Reference [3] for information about destroying the JPEG decoder The following code example uses these functions to decode an MJPEG AVI stream. /* SETUP MJPEG DECODER */ /* Read the JPEG information from the first frame of the previously encoded stream */ JPEG_Param_INIT(&lImageParam); lresult = MJPEG_AVI_GetImageInfo(lStreamFileInName, &limageparam, &lminstreambuflength, TestReportFile); /* Open the AVI file */ lresult = MJPEG_AVI_OpenFileRead(&lStreamFileInHandle, (int8 *)lstreamfileinname); /* Get the handle for AVI stream */ lresult = MJPEG_AVI_OpenStreamRead (lstreamfileinhandle, &lstreamhandle, MJPEG_AVI_StreamTypeVIDEO, 0); lresult = MJPEG_AVI_RewindToFirstFrame(lStreamHandle, &lstreambufferlength); StreamBuffer_Obj = JPEG_MemAlloc_NEW(lStreamBufferLength,1,MEM_TYPE_DATA); lstreambuffer = (uint8*)jpeg_memalloc_address(streambuffer_obj); lresult = MJPEG_AVI_ReadNextFrame(lStreamHandle, lstreambuffer, &lminstreambuflength); /* SETUP JPEG DECODER */ /*... Create the input stream buffer and output frame buffer here... */ lstreambufferinfo.length = lstreambufferlength; lstreambufferinfo.pointer = lstreambuffer; JPEG_Param_CONFIG(&lImageParam, JPEG_POINTER_INPUT, (int)(&lstreambufferinfo)); JPEG_Param_CONFIG(&lImageParam, JPEG_POINTER_OUTPUT, (int)lframebuffer); DEVIM1-002-D Proprietary and Confidential Page 11 of 17

/* Creating the JPEG decoder instance */ ljpegdec = JPEG_Decoder_NEW(&lImageParam); lresult = JPEG_ProcessHeader(lJpegDec, &limageparam); lresult = MJPEG_AVI_RewindToFirstFrame(lStreamHandle, &lstreambufferlength); /* DECODE EACH FRAME */ isinputdataavailable = E_TRUE; while (E_TRUE == isinputdataavailable) { /* Read the frame */ lresult = MJPEG_AVI_ReadNextFrame(lStreamHandle, lstreambuffer, lstreambufferlength); if(lresult!= ) { if (lresult == MJPEG_AVI_RETURN_NOMORESAMPLES) { fprintf(testreportfile, "\n*** End of MJPEG stream ***\n"); break; } else { fprintf(testreportfile, "Cannot read next frame of the MJPEG stream\n"); exit (EXITERROR); } } /* Decode image */ lresult = JPEG_DecodeImage(lJpegDec, &limageparam); /*... Write the decoded image from the frame buffer here...*/ }; // For each frame /************************************/ /* FINALISE AND DESTROY DECODER */ /************************************/ /* Close the AVI stream*/ lresult = MJPEG_AVI_CloseStreamRead(lStreamHandle); /* Close the output file*/ lresult = MJPEG_AVI_CloseFileRead(lStreamFileInHandle); /* Free and destroy used resources */ JPEG_Decoder_DELETE(lJpegDec); 4. Programmer s Reference This section uses two examples to show each of the functions in the MJPEG AVI library. A reference for each function is also provided. The function arguments are described in the Parameters sections as [IN] or [OUT]. This defines whether the function will read (IN pointers) or write to the memory (OUT pointers). DEVIM1-002-D Proprietary and Confidential Page 12 of 17

4.1. MJPEG AVI Encoder Library This section describes MJPEG AVI API functions required for encoding operations. 4.1.1. MJPEG_AVI_OpenFileWrite int32 MJPEG_AVI_OpenFileWrite(uint32 *pavifilehandle, uint8 *filename, tjpegparam *ImageParam, uint32 FrameRate) pavifilehandle [OUT] Pointer to the output file handle filename [IN] Pointer to the null-terminated filename ImageParam [IN] Pointer to JPEG image parameters. FrameRate [IN] Frame rate (frames/second) if file opened OK Opens an MJPEG AVI file output file for encoding and create intermediate AVI header. 4.1.2. MJPEG_AVI_CloseFileWrite int32 MJPEG_AVI_CloseFileWrite(uint32 AVIFileHandle) AVIFileHandle [IN] MJPEG AVI output file handle if file opened OK Append index table, update AVI header, and close the MJPEG AVI output file. 4.1.3. MJPEG_AVI_OpenStreamWrite int32 MJPEG_AVI_OpenStreamWrite( uint32 AVIFileHandle, uint32 *pavistreamhandle, tmjpeg_avi_streaminfo *pstreaminfo) AVIFileHandle [IN] MJPEG AVI file handle pavistreamhandle [OUT] Pointer to stream handle pstreaminfo [IN] Pointer to stream information if file opened OK Creates and opens an MJPEG AVI output stream DEVIM1-002-D Proprietary and Confidential Page 13 of 17

4.1.4. MJPEG_AVI_CloseStreamWrite int32 MJPEG_AVI_CloseStreamWrite(uint32 AVIStreamHandle) AVIStreamHandle [IN] MJPEG AVI stream handle if stream closed OK Closes and destroys an MJPEG AVI output stream. 4.1.5. MJPEG_AVI_WriteStream int32 MJPEG_AVI_WriteStream( uint32 AVIStreamHandle, uint8 *pdatabuffer, uint32 datalength, uint8 IsKeyFrame) AVIStreamHandle [IN] MJPEG AVI stream handle pdatabuffer [IN] Pointer to data buffer. datalength [IN] Length of data buffer IsKeyFrame [IN] Sets the key frame indicator flag at the current location if equal to 1 if data written OK MJPEG_AVI_RETURN_EVALUATIONLIMITREACHED if an evaluation package has reached its limit Write the given data to the MJPEG AVI stream. If IsKeyFrame = 1, a keyframe is flagged in the bitstream at the current position. 4.2. MJPEG AVI Decoder Library This section describes MJPEG AVI API functions required for AVI decoding operations using the JPEG decoder library. 4.2.1. MJPEG_AVI_OpenFileRead int32 MJPEG_AVI_OpenFileRead(uint32 *pavifilehandle, int8 *filename) pavifilehandle [OUT] Pointer to receive the AVI File Handle filename [IN] Name of the AVI file to be opened if file opened OK MJPEG_AVI_RETURN_OUTOFMEMORY if memory could not be allocated when opening the file MJPEG_AVI_RETURN_FILEOPENFAIL if the input file could not be opened MJPEG_AVI_RETURN_FILEREADFAIL if the input file could not be read MJPEG_AVI_RETURN_FILEINCORRECTFORMAT if the input file was not in MJPEG AVI format DEVIM1-002-D Proprietary and Confidential Page 14 of 17

MJPEG_AVI_RETURN_FILESEEKFAIL if the seek operation on the input file failed Opens the MJPEG AVI file for reading. Assumptions: 1. The index table (i.e. idx1 chunk) is assumed to be present in the file. 4.2.2. MJPEG_AVI_CloseFileRead int32 MJPEG_AVI_CloseFileRead(uint32 AVIFileHandle) AVIFileHandle [IN] AVI File Handle if file closed OK Closes the AVI file. 4.2.3. MJPEG_AVI_OpenStreamRead int32 MJPEG_AVI_OpenStreamRead( uint32 AVIFileHandle, uint32 *pavistreamhandle, uint32 fcctype, int32 index) AVIFileHandle [IN] Handle of input AVI file pavistreamhandle [OUT] Pointer to receive the stream handle after the stream is opened fcctype [IN] FCC file type. index [IN] Index of the stream to be opened. if file opened OK MJPEG_AVI_RETURN_OUTOFMEMORY if memory could not be allocated when opening the file MJPEG_AVI_RETURN_FILEOPENFAIL if the input file could not be opened MJPEG_AVI_RETURN_FILEREADFAIL if the input file could not be read MJPEG_AVI_RETURN_FILEINCORRECTFORMAT if the input file was not in MJPEG AVI format MJPEG_AVI_RETURN_FILESEEKFAIL if the seek operation on the input file failed Assigns a stream handle to the AVI file. Limitations : 1. index is supported only for value 0. 2. fcctypeparam is supported for values "MJPEG_AVI_StreamTypeVIDEO" and "MJPEG_AVI_StreamTypeAUDIO" Assumptions : 1. The strl chunk index in the avih header is same as the corresponding stream's stream identifier DEVIM1-002-D Proprietary and Confidential Page 15 of 17

4.2.4. MJPEG_AVI_CloseStreamRead int32 MJPEG_AVI_CloseStreamRead(uint32 AVIStreamHandle) AVIStreamHandle [IN] Handle of the AVI Stream Handle to be closed. if stream closed OK Closes the AVI stream 4.2.5. MJPEG_AVI_RewindToFirstFrame int32 MJPEG_AVI_RewindToFirstFrame(uint32 AVIStreamHandle, uint32 *pbuflength) AVIStreamHandle [IN] Handle of input AVI stream pbuflength [OUT] Pointer to receive the size of the next frame (in bytes) if file opened OK MJPEG_AVI_RETURN_OUTOFMEMORY if memory could not be allocated when opening the file MJPEG_AVI_RETURN_FILEOPENFAIL if the input file could not be opened MJPEG_AVI_RETURN_FILEREADFAIL if the input file could not be read MJPEG_AVI_RETURN_FILEINCORRECTFORMAT if the input file was not in MJPEG AVI format MJPEG_AVI_RETURN_FILESEEKFAIL if the seek operation on the input file failed MJPEG_AVI_RETURN_NOMORESAMPLES if no more frames are available to be read MJPEG_AVI_RETURN_EVALUATIONLIMITREACHED if an evaluation package has reached its limit Rewind the AVI stream up to the start of the JPEG image of the first frame. Returns the maximum number of bytes in al the subsequent JPEG images. DEVIM1-002-D Proprietary and Confidential Page 16 of 17

4.2.6. MJPEG_AVI_ReadNextFrame int32 MJPEG_AVI_ReadNextFrame(uint32 AVIStreamHandle, void* pbuffer, uint32 *pbuflength) AVIStreamHandle [IN] Handle of input AVI stream pbuffer [OUT] Pointer to the frame buffer pbuflength [OUT] The length of the next frame if file opened OK MJPEG_AVI_RETURN_STREAMINVALID if the supplied stream handle is invalid MJPEG_AVI_RETURN_FILEREADFAIL if the input file could not be read Reads the next image frame into the supplied buffer. DEVIM1-002-D Proprietary and Confidential Page 17 of 17