package theora

  1. Overview
  2. Docs

* Functions for encoding theora files using libtheora. * *

  • author Samuel Mimram

*

  • author Romain Beauxis

Exceptions

exception Internal_error

General failure.

exception Invalid_data

Library encountered invalid internal data.

exception Unknown_error of int

An unhandled error happened.

exception Duplicate_frame

The decoded packet represented a dropped frame. * The player can continue to display the current frame, * as the contents of the decoded frame buffer have not * changed.

exception Done

Exceptions used by the decoding module.

exception Not_initialized
exception Bad_packet
exception Header_not_theora
exception Bad_header
exception Not_implemented

General functions

val version_string : string

* Human-readable string to identify the encoder vendor and version.

val version_number : int * int * int

major, minor and sub version numbers of the encoder.

val is_keyframe : Ogg.Stream.packet -> bool

Determines whether a theora packet is a key frame or not. * * raises Invalid_data if The packet is not a video data * packet.

Types and datastructures

type colorspace =
  1. | CS_unspecified
    (*

    The colorspace is unknown or unspecified

    *)
  2. | CS_ITU_REC_470M
    (*

    This is the best option for 'NTSC' content

    *)
  3. | CS_ITU_REC_470BG
    (*

    This is the best option for 'PAL' content

    *)
  4. | CS_NSPACES
    (*

    This marks the end of the defined colorspaces

    *)

A Colorspace.

type pixelformat =
  1. | PF_420
    (*

    Chroma subsampling by 2 in each direction (4:2:0)

    *)
  2. | PF_reserved
    (*

    Reserved value

    *)
  3. | PF_422
    (*

    Horizonatal chroma subsampling by 2 (4:2:2)

    *)
  4. | PF_444
    (*

    No chroma subsampling at all (4:4:4)

    *)

* A Chroma subsampling * * These enumerate the available chroma subsampling options supported * by the theora format. See Section 4.4 of the specification for * exact definitions.

type info = {
  1. frame_width : int;
    (*

    The encoded frame width.

    *)
  2. frame_height : int;
    (*

    The encoded frame height.

    *)
  3. picture_width : int;
    (*

    The displayed picture width.

    *)
  4. picture_height : int;
    (*

    The displayed picture height.

    *)
  5. picture_x : int;
    (*

    The X offset of the displayed picture.

    *)
  6. picture_y : int;
    (*

    The Y offset of the displayed picture.

    *)
  7. colorspace : colorspace;
    (*

    The color space.

    *)
  8. pixel_fmt : pixelformat;
    (*

    The pixel format.

    *)
  9. target_bitrate : int;
    (*

    The target bit-rate in bits per second.

    *)
  10. quality : int;
    (*

    The target quality level.

    *)
  11. keyframe_granule_shift : int;
    (*

    The amount to shift to extract the last keyframe number from the granule position.

    *)
  12. version_major : int;
  13. version_minor : int;
  14. version_subminor : int;
  15. fps_numerator : int;
  16. fps_denominator : int;
  17. aspect_numerator : int;
  18. aspect_denominator : int;
}

Theora bitstream info.

val default_granule_shift : int
type yuv_buffer = {
  1. y_width : int;
  2. y_height : int;
  3. y_stride : int;
  4. y : data_buffer;
  5. u_width : int;
  6. u_height : int;
  7. u_stride : int;
  8. u : data_buffer;
  9. v_width : int;
  10. v_height : int;
  11. v_stride : int;
  12. v : data_buffer;
}

* A YUV buffer for passing uncompressed frames to and from the codec. * This holds a Y'CbCr frame in planar format. The CbCr planes can be * subsampled and have their own separate dimensions and row stride * offsets. Note that the strides may be negative in some * configurations. For theora the width and height of the largest plane * must be a multiple of 16. The actual meaningful picture size and * offset are stored in the info structure; frames returned by * the decoder may need to be cropped for display. * * All samples are 8 bits. Within each plane samples are ordered by * row from the top of the frame to the bottom. Within each row samples * are ordered from left to right.

Encoding

module Encoder : sig ... end
module Decoder : sig ... end
module Skeleton : sig ... end
OCaml

Innovation. Community. Security.