Skip to content

Commit

Permalink
Merge pull request #2458 from mohamedchebbii/TestVideoData
Browse files Browse the repository at this point in the history
Rework Asf, Riff video, test data and fix OSS-Fuzz issues
  • Loading branch information
neheb authored Feb 9, 2023
2 parents 84c3c47 + 6690e2e commit aa16a54
Show file tree
Hide file tree
Showing 16 changed files with 1,022 additions and 1,528 deletions.
92 changes: 34 additions & 58 deletions include/exiv2/asfvideo.hpp
Original file line number Diff line number Diff line change
@@ -1,31 +1,7 @@
// ***************************************************************** -*- C++ -*-
/*
* Copyright (C) 2004-2021 Exiv2 authors
* This program is part of the Exiv2 distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA.
*/
/*!
@file asfvideo.hpp
@brief An Image subclass to support ASF video files
@author Abhinav Badola for GSoC 2012
<a href="mailto:mail.abu.to@gmail.com">mail.abu.to@gmail.com</a>
@date 08-Aug-12, AB: created
*/
#ifndef ASFVIDEO_HPP
#define ASFVIDEO_HPP
// SPDX-License-Identifier: GPL-2.0-or-later
// Spec : Advanced Systems Format (ASF) Specification : Revision 01.20.05 :
// https://exse.eyewated.com/fls/54b3ed95bbfb1a92.pdf
#pragma once

// *****************************************************************************
#include "exiv2lib_export.h"
Expand Down Expand Up @@ -72,26 +48,36 @@ class EXIV2API AsfVideo : public Image {
[[nodiscard]] std::string mimeType() const override;
//@}
private:
static constexpr size_t ASF_TAG_SIZE = 0x4;
static constexpr size_t BUFF_MIN_SIZE = 0x8;
static constexpr size_t GUI_SIZE = 16;
static constexpr size_t GUID_SIZE = 37;
static constexpr size_t CODEC_TYPE_VIDEO = 1;
static constexpr size_t CODEC_TYPE_AUDIO = 2;

class HeaderReader {
DataBuf IdBuf_;
uint64_t size_;
uint64_t remaining_size_;

public:
explicit HeaderReader(BasicIo::UniquePtr& io);

[[nodiscard]] uint64_t getSize() const {
return size_;
}

[[nodiscard]] uint64_t getRemainingSize() const {
return remaining_size_;
}

[[nodiscard]] DataBuf& getId() {
return IdBuf_;
}
};

protected:
/*!
@brief Check for a valid tag and decode the block at the current IO
position. Calls tagDecoder() or skips to next tag, if required.
*/
void decodeBlock();
/*!
@brief Interpret tag information, and call the respective function
to save it in the respective XMP container. Decodes a Tag
Information and saves it in the respective XMP container, if
the block size is small.
@param tv Pointer to current tag,
@param size Size of the data block used to store Tag Information.
*/
void tagDecoder(uint64_t size);
/*!
@brief Interpret File_Properties tag information, and save it in
the respective XMP container.
Expand All @@ -112,40 +98,33 @@ class EXIV2API AsfVideo : public Image {
in the respective XMP container.
@param size Size of the data block used to store Tag Data.
*/
void contentDescription(uint64_t size);
void contentDescription();
/*!
@brief Interpret Extended_Stream_Properties tag information, and
save it in the respective XMP container.
@param size Size of the data block used to store Tag Data.
*/
void extendedStreamProperties(uint64_t size);
void extendedStreamProperties();
/*!
@brief Interpret Header_Extension tag information, and save it in
the respective XMP container.
@param size Size of the data block used to store Tag Data.
*/
void headerExtension(uint64_t size);
void headerExtension();
/*!
@brief Interpret Metadata, Extended_Content_Description,
Metadata_Library tag information, and save it in the respective
XMP container.
@param meta A default integer which helps to overload the function
for various Tags that have a similar method of decoding.
*/
void metadataHandler(int meta = 1);
void extendedContentDescription();

void DegradableJPEGMedia();

/*!
@brief Calculates Aspect Ratio of a video, and stores it in the
respective XMP container.
*/
void aspectRatio();

private:
//! Variable to check the end of metadata traversing.
bool continueTraversing_;
//! Variable which stores current position of the read pointer.
uint64_t localPosition_;
//! Variable which stores current stream being processsed.
int streamNumber_;
//! Variable to store height and width of a video frame.
uint64_t height_, width_;

Expand All @@ -165,7 +144,4 @@ EXIV2API Image::UniquePtr newAsfInstance(BasicIo::UniquePtr io, bool create);

//! Check if the file iIo is a Windows Asf Video.
EXIV2API bool isAsfType(BasicIo& iIo, bool advance);

} // namespace Exiv2

#endif // #ifndef ASFVIDEO_HPP_
Loading

0 comments on commit aa16a54

Please sign in to comment.