Bug 1460966 - lib/apiwrapper.c & lib/decapiwrapper.c are unused r?cpearce draft
authorSylvestre Ledru <sledru@mozilla.com>
Fri, 11 May 2018 21:17:59 +0200
changeset 794435 b6fc1b9ac2d33fd24cef10f42b52599dffa610a7
parent 794191 4303d49c53931385892231969e40048f096b4d4c
push id109695
push usersledru@mozilla.com
push dateSat, 12 May 2018 08:32:15 +0000
reviewerscpearce
bugs1460966
milestone62.0a1
Bug 1460966 - lib/apiwrapper.c & lib/decapiwrapper.c are unused r?cpearce Remove them MozReview-Commit-ID: G1ku9mvus3D
media/libtheora/lib/apiwrapper.c
media/libtheora/lib/apiwrapper.h
media/libtheora/lib/decapiwrapper.c
media/libtheora/moz.build
media/libtheora/update.sh
deleted file mode 100644
--- a/media/libtheora/lib/apiwrapper.c
+++ /dev/null
@@ -1,166 +0,0 @@
-/********************************************************************
- *                                                                  *
- * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
- * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
- * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
- * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
- *                                                                  *
- * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009                *
- * by the Xiph.Org Foundation and contributors http://www.xiph.org/ *
- *                                                                  *
- ********************************************************************
-
-  function:
-    last mod: $Id: apiwrapper.c 16503 2009-08-22 18:14:02Z giles $
-
- ********************************************************************/
-
-#include <stdlib.h>
-#include <string.h>
-#include <limits.h>
-#include "apiwrapper.h"
-
-
-
-const char *theora_version_string(void){
-  return th_version_string();
-}
-
-ogg_uint32_t theora_version_number(void){
-  return th_version_number();
-}
-
-void theora_info_init(theora_info *_ci){
-  memset(_ci,0,sizeof(*_ci));
-}
-
-void theora_info_clear(theora_info *_ci){
-  th_api_wrapper *api;
-  api=(th_api_wrapper *)_ci->codec_setup;
-  memset(_ci,0,sizeof(*_ci));
-  if(api!=NULL){
-    if(api->clear!=NULL)(*api->clear)(api);
-    _ogg_free(api);
-  }
-}
-
-void theora_clear(theora_state *_th){
-  /*Provide compatibility with mixed encoder and decoder shared lib versions.*/
-  if(_th->internal_decode!=NULL){
-    (*((oc_state_dispatch_vtable *)_th->internal_decode)->clear)(_th);
-  }
-  if(_th->internal_encode!=NULL){
-    (*((oc_state_dispatch_vtable *)_th->internal_encode)->clear)(_th);
-  }
-  if(_th->i!=NULL)theora_info_clear(_th->i);
-  memset(_th,0,sizeof(*_th));
-}
-
-int theora_control(theora_state *_th,int _req,void *_buf,size_t _buf_sz){
-  /*Provide compatibility with mixed encoder and decoder shared lib versions.*/
-  if(_th->internal_decode!=NULL){
-    return (*((oc_state_dispatch_vtable *)_th->internal_decode)->control)(_th,
-     _req,_buf,_buf_sz);
-  }
-  else if(_th->internal_encode!=NULL){
-    return (*((oc_state_dispatch_vtable *)_th->internal_encode)->control)(_th,
-     _req,_buf,_buf_sz);
-  }
-  else return TH_EINVAL;
-}
-
-ogg_int64_t theora_granule_frame(theora_state *_th,ogg_int64_t _gp){
-  /*Provide compatibility with mixed encoder and decoder shared lib versions.*/
-  if(_th->internal_decode!=NULL){
-    return (*((oc_state_dispatch_vtable *)_th->internal_decode)->granule_frame)(
-     _th,_gp);
-  }
-  else if(_th->internal_encode!=NULL){
-    return (*((oc_state_dispatch_vtable *)_th->internal_encode)->granule_frame)(
-     _th,_gp);
-  }
-  else return -1;
-}
-
-double theora_granule_time(theora_state *_th, ogg_int64_t _gp){
-  /*Provide compatibility with mixed encoder and decoder shared lib versions.*/
-  if(_th->internal_decode!=NULL){
-    return (*((oc_state_dispatch_vtable *)_th->internal_decode)->granule_time)(
-     _th,_gp);
-  }
-  else if(_th->internal_encode!=NULL){
-    return (*((oc_state_dispatch_vtable *)_th->internal_encode)->granule_time)(
-     _th,_gp);
-  }
-  else return -1;
-}
-
-void oc_theora_info2th_info(th_info *_info,const theora_info *_ci){
-  _info->version_major=_ci->version_major;
-  _info->version_minor=_ci->version_minor;
-  _info->version_subminor=_ci->version_subminor;
-  _info->frame_width=_ci->width;
-  _info->frame_height=_ci->height;
-  _info->pic_width=_ci->frame_width;
-  _info->pic_height=_ci->frame_height;
-  _info->pic_x=_ci->offset_x;
-  _info->pic_y=_ci->offset_y;
-  _info->fps_numerator=_ci->fps_numerator;
-  _info->fps_denominator=_ci->fps_denominator;
-  _info->aspect_numerator=_ci->aspect_numerator;
-  _info->aspect_denominator=_ci->aspect_denominator;
-  switch(_ci->colorspace){
-    case OC_CS_ITU_REC_470M:_info->colorspace=TH_CS_ITU_REC_470M;break;
-    case OC_CS_ITU_REC_470BG:_info->colorspace=TH_CS_ITU_REC_470BG;break;
-    default:_info->colorspace=TH_CS_UNSPECIFIED;break;
-  }
-  switch(_ci->pixelformat){
-    case OC_PF_420:_info->pixel_fmt=TH_PF_420;break;
-    case OC_PF_422:_info->pixel_fmt=TH_PF_422;break;
-    case OC_PF_444:_info->pixel_fmt=TH_PF_444;break;
-    default:_info->pixel_fmt=TH_PF_RSVD;
-  }
-  _info->target_bitrate=_ci->target_bitrate;
-  _info->quality=_ci->quality;
-  _info->keyframe_granule_shift=_ci->keyframe_frequency_force>0?
-   OC_MINI(31,oc_ilog(_ci->keyframe_frequency_force-1)):0;
-}
-
-int theora_packet_isheader(ogg_packet *_op){
-  return th_packet_isheader(_op);
-}
-
-int theora_packet_iskeyframe(ogg_packet *_op){
-  return th_packet_iskeyframe(_op);
-}
-
-int theora_granule_shift(theora_info *_ci){
-  /*This breaks when keyframe_frequency_force is not positive or is larger than
-     2**31 (if your int is more than 32 bits), but that's what the original
-     function does.*/
-  return oc_ilog(_ci->keyframe_frequency_force-1);
-}
-
-void theora_comment_init(theora_comment *_tc){
-  th_comment_init((th_comment *)_tc);
-}
-
-char *theora_comment_query(theora_comment *_tc,char *_tag,int _count){
-  return th_comment_query((th_comment *)_tc,_tag,_count);
-}
-
-int theora_comment_query_count(theora_comment *_tc,char *_tag){
-  return th_comment_query_count((th_comment *)_tc,_tag);
-}
-
-void theora_comment_clear(theora_comment *_tc){
-  th_comment_clear((th_comment *)_tc);
-}
-
-void theora_comment_add(theora_comment *_tc,char *_comment){
-  th_comment_add((th_comment *)_tc,_comment);
-}
-
-void theora_comment_add_tag(theora_comment *_tc, char *_tag, char *_value){
-  th_comment_add_tag((th_comment *)_tc,_tag,_value);
-}
deleted file mode 100644
--- a/media/libtheora/lib/apiwrapper.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/********************************************************************
- *                                                                  *
- * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
- * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
- * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
- * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
- *                                                                  *
- * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009                *
- * by the Xiph.Org Foundation and contributors http://www.xiph.org/ *
- *                                                                  *
- ********************************************************************
-
-  function:
-    last mod: $Id: apiwrapper.h 13596 2007-08-23 20:05:38Z tterribe $
-
- ********************************************************************/
-
-#if !defined(_apiwrapper_H)
-# define _apiwrapper_H (1)
-# include <ogg/ogg.h>
-# include <theora/theora.h>
-# include "theora/theoradec.h"
-# include "theora/theoraenc.h"
-# include "state.h"
-
-typedef struct th_api_wrapper th_api_wrapper;
-typedef struct th_api_info    th_api_info;
-
-/*Provide an entry point for the codec setup to clear itself in case we ever
-   want to break pieces off into a common base library shared by encoder and
-   decoder.
-  In addition, this makes several other pieces of the API wrapper cleaner.*/
-typedef void (*oc_setup_clear_func)(void *_ts);
-
-/*Generally only one of these pointers will be non-NULL in any given instance.
-  Technically we do not even really need this struct, since we should be able
-   to figure out which one from "context", but doing it this way makes sure we
-   don't flub it up.*/
-struct th_api_wrapper{
-  oc_setup_clear_func  clear;
-  th_setup_info       *setup;
-  th_dec_ctx          *decode;
-  th_enc_ctx          *encode;
-};
-
-struct th_api_info{
-  th_api_wrapper api;
-  theora_info    info;
-};
-
-
-void oc_theora_info2th_info(th_info *_info,const theora_info *_ci);
-
-#endif
deleted file mode 100644
--- a/media/libtheora/lib/decapiwrapper.c
+++ /dev/null
@@ -1,193 +0,0 @@
-/********************************************************************
- *                                                                  *
- * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
- * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
- * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
- * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
- *                                                                  *
- * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009                *
- * by the Xiph.Org Foundation and contributors http://www.xiph.org/ *
- *                                                                  *
- ********************************************************************
-
-  function:
-    last mod: $Id: decapiwrapper.c 13596 2007-08-23 20:05:38Z tterribe $
-
- ********************************************************************/
-
-#include <stdlib.h>
-#include <string.h>
-#include <limits.h>
-#include "apiwrapper.h"
-#include "decint.h"
-#include "theora/theoradec.h"
-
-static void th_dec_api_clear(th_api_wrapper *_api){
-  if(_api->setup)th_setup_free(_api->setup);
-  if(_api->decode)th_decode_free(_api->decode);
-  memset(_api,0,sizeof(*_api));
-}
-
-static void theora_decode_clear(theora_state *_td){
-  if(_td->i!=NULL)theora_info_clear(_td->i);
-  memset(_td,0,sizeof(*_td));
-}
-
-static int theora_decode_control(theora_state *_td,int _req,
- void *_buf,size_t _buf_sz){
-  return th_decode_ctl(((th_api_wrapper *)_td->i->codec_setup)->decode,
-   _req,_buf,_buf_sz);
-}
-
-static ogg_int64_t theora_decode_granule_frame(theora_state *_td,
- ogg_int64_t _gp){
-  return th_granule_frame(((th_api_wrapper *)_td->i->codec_setup)->decode,_gp);
-}
-
-static double theora_decode_granule_time(theora_state *_td,ogg_int64_t _gp){
-  return th_granule_time(((th_api_wrapper *)_td->i->codec_setup)->decode,_gp);
-}
-
-static const oc_state_dispatch_vtable OC_DEC_DISPATCH_VTBL={
-  (oc_state_clear_func)theora_decode_clear,
-  (oc_state_control_func)theora_decode_control,
-  (oc_state_granule_frame_func)theora_decode_granule_frame,
-  (oc_state_granule_time_func)theora_decode_granule_time,
-};
-
-static void th_info2theora_info(theora_info *_ci,const th_info *_info){
-  _ci->version_major=_info->version_major;
-  _ci->version_minor=_info->version_minor;
-  _ci->version_subminor=_info->version_subminor;
-  _ci->width=_info->frame_width;
-  _ci->height=_info->frame_height;
-  _ci->frame_width=_info->pic_width;
-  _ci->frame_height=_info->pic_height;
-  _ci->offset_x=_info->pic_x;
-  _ci->offset_y=_info->pic_y;
-  _ci->fps_numerator=_info->fps_numerator;
-  _ci->fps_denominator=_info->fps_denominator;
-  _ci->aspect_numerator=_info->aspect_numerator;
-  _ci->aspect_denominator=_info->aspect_denominator;
-  switch(_info->colorspace){
-    case TH_CS_ITU_REC_470M:_ci->colorspace=OC_CS_ITU_REC_470M;break;
-    case TH_CS_ITU_REC_470BG:_ci->colorspace=OC_CS_ITU_REC_470BG;break;
-    default:_ci->colorspace=OC_CS_UNSPECIFIED;break;
-  }
-  switch(_info->pixel_fmt){
-    case TH_PF_420:_ci->pixelformat=OC_PF_420;break;
-    case TH_PF_422:_ci->pixelformat=OC_PF_422;break;
-    case TH_PF_444:_ci->pixelformat=OC_PF_444;break;
-    default:_ci->pixelformat=OC_PF_RSVD;
-  }
-  _ci->target_bitrate=_info->target_bitrate;
-  _ci->quality=_info->quality;
-  _ci->keyframe_frequency_force=1<<_info->keyframe_granule_shift;
-}
-
-int theora_decode_init(theora_state *_td,theora_info *_ci){
-  th_api_info    *apiinfo;
-  th_api_wrapper *api;
-  th_info         info;
-  api=(th_api_wrapper *)_ci->codec_setup;
-  /*Allocate our own combined API wrapper/theora_info struct.
-    We put them both in one malloc'd block so that when the API wrapper is
-     freed, the info struct goes with it.
-    This avoids having to figure out whether or not we need to free the info
-     struct in either theora_info_clear() or theora_clear().*/
-  apiinfo=(th_api_info *)_ogg_calloc(1,sizeof(*apiinfo));
-  if(apiinfo==NULL)return OC_FAULT;
-  /*Make our own copy of the info struct, since its lifetime should be
-     independent of the one we were passed in.*/
-  *&apiinfo->info=*_ci;
-  /*Convert the info struct now instead of saving the the one we decoded with
-     theora_decode_header(), since the user might have modified values (i.e.,
-     color space, aspect ratio, etc. can be specified from a higher level).
-    The user also might be doing something "clever" with the header packets if
-     they are not using an Ogg encapsulation.*/
-  oc_theora_info2th_info(&info,_ci);
-  /*Don't bother to copy the setup info; th_decode_alloc() makes its own copy
-     of the stuff it needs.*/
-  apiinfo->api.decode=th_decode_alloc(&info,api->setup);
-  if(apiinfo->api.decode==NULL){
-    _ogg_free(apiinfo);
-    return OC_EINVAL;
-  }
-  apiinfo->api.clear=(oc_setup_clear_func)th_dec_api_clear;
-  _td->internal_encode=NULL;
-  /*Provide entry points for ABI compatibility with old decoder shared libs.*/
-  _td->internal_decode=(void *)&OC_DEC_DISPATCH_VTBL;
-  _td->granulepos=0;
-  _td->i=&apiinfo->info;
-  _td->i->codec_setup=&apiinfo->api;
-  return 0;
-}
-
-int theora_decode_header(theora_info *_ci,theora_comment *_cc,ogg_packet *_op){
-  th_api_wrapper *api;
-  th_info         info;
-  int             ret;
-  api=(th_api_wrapper *)_ci->codec_setup;
-  /*Allocate an API wrapper struct on demand, since it will not also include a
-     theora_info struct like the ones that are used in a theora_state struct.*/
-  if(api==NULL){
-    _ci->codec_setup=_ogg_calloc(1,sizeof(*api));
-    if(_ci->codec_setup==NULL)return OC_FAULT;
-    api=(th_api_wrapper *)_ci->codec_setup;
-    api->clear=(oc_setup_clear_func)th_dec_api_clear;
-  }
-  /*Convert from the theora_info struct instead of saving our own th_info
-     struct between calls.
-    The user might be doing something "clever" with the header packets if they
-     are not using an Ogg encapsulation, and we don't want to break this.*/
-  oc_theora_info2th_info(&info,_ci);
-  /*We rely on the fact that theora_comment and th_comment structures are
-     actually identical.
-    Take care not to change this fact unless you change the code here as
-     well!*/
-  ret=th_decode_headerin(&info,(th_comment *)_cc,&api->setup,_op);
-  /*We also rely on the fact that the error return code values are the same,
-    and that the implementations of these two functions return the same set of
-    them.
-   Note that theora_decode_header() really can return OC_NOTFORMAT, even
-    though it is not currently documented to do so.*/
-  if(ret<0)return ret;
-  th_info2theora_info(_ci,&info);
-  return 0;
-}
-
-int theora_decode_packetin(theora_state *_td,ogg_packet *_op){
-  th_api_wrapper *api;
-  ogg_int64_t     gp;
-  int             ret;
-  if(!_td||!_td->i||!_td->i->codec_setup)return OC_FAULT;
-  api=(th_api_wrapper *)_td->i->codec_setup;
-  ret=th_decode_packetin(api->decode,_op,&gp);
-  if(ret<0)return OC_BADPACKET;
-  _td->granulepos=gp;
-  return 0;
-}
-
-int theora_decode_YUVout(theora_state *_td,yuv_buffer *_yuv){
-  th_api_wrapper  *api;
-  th_dec_ctx      *decode;
-  th_ycbcr_buffer  buf;
-  int              ret;
-  if(!_td||!_td->i||!_td->i->codec_setup)return OC_FAULT;
-  api=(th_api_wrapper *)_td->i->codec_setup;
-  decode=(th_dec_ctx *)api->decode;
-  if(!decode)return OC_FAULT;
-  ret=th_decode_ycbcr_out(decode,buf);
-  if(ret>=0){
-    _yuv->y_width=buf[0].width;
-    _yuv->y_height=buf[0].height;
-    _yuv->y_stride=buf[0].stride;
-    _yuv->uv_width=buf[1].width;
-    _yuv->uv_height=buf[1].height;
-    _yuv->uv_stride=buf[1].stride;
-    _yuv->y=buf[0].data;
-    _yuv->u=buf[1].data;
-    _yuv->v=buf[2].data;
-  }
-  return ret;
-}
--- a/media/libtheora/moz.build
+++ b/media/libtheora/moz.build
@@ -28,19 +28,17 @@ if CONFIG['CC_TYPE'] in ('clang', 'clang
     CFLAGS += ['-Wno-tautological-compare']
 if CONFIG['CC_TYPE'] == 'clang-cl':
     CFLAGS += [
         '-Wno-pointer-sign',
         '-Wno-shift-op-parentheses',
     ]
 
 UNIFIED_SOURCES += [
-    'lib/apiwrapper.c',
     'lib/bitpack.c',
-    'lib/decapiwrapper.c',
     'lib/decinfo.c',
     'lib/decode.c',
     'lib/dequant.c',
     'lib/fragment.c',
     'lib/huffdec.c',
     'lib/idct.c',
     'lib/info.c',
     'lib/internal.c',
--- a/media/libtheora/update.sh
+++ b/media/libtheora/update.sh
@@ -16,22 +16,19 @@ sed \
  -e s/@HAVE_ARM_ASM_MEDIA@/1/g \
  -e s/@HAVE_ARM_ASM_NEON@/1/g \
  $1/lib/arm/armopts.s.in > lib/arm/armopts.s
 cp $1/LICENSE ./LICENSE
 cp $1/CHANGES ./CHANGES
 cp $1/COPYING ./COPYING
 cp $1/README ./README
 cp $1/AUTHORS ./AUTHORS
-cp $1/lib/apiwrapper.c ./lib/
-cp $1/lib/apiwrapper.h ./lib/
 cp $1/lib/bitpack.c ./lib/
 cp $1/lib/bitpack.h ./lib/
 cp $1/lib/dct.h ./lib/
-cp $1/lib/decapiwrapper.c ./lib/
 cp $1/lib/decinfo.c ./lib/
 cp $1/lib/decint.h ./lib/
 cp $1/lib/decode.c ./lib/
 cp $1/lib/dequant.c ./lib/
 cp $1/lib/dequant.h ./lib/
 cp $1/lib/fragment.c ./lib/
 cp $1/lib/huffdec.c ./lib/
 cp $1/lib/huffdec.h ./lib/