bitstream_filter.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
  3. *
  4. * This file is part of FFmpeg.
  5. *
  6. * FFmpeg is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * FFmpeg is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with FFmpeg; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #include "avcodec.h"
  21. static AVBitStreamFilter *first_bitstream_filter= NULL;
  22. AVBitStreamFilter *av_bitstream_filter_next(AVBitStreamFilter *f){
  23. if(f) return f->next;
  24. else return first_bitstream_filter;
  25. }
  26. void av_register_bitstream_filter(AVBitStreamFilter *bsf){
  27. bsf->next = first_bitstream_filter;
  28. first_bitstream_filter= bsf;
  29. }
  30. AVBitStreamFilterContext *av_bitstream_filter_init(const char *name){
  31. AVBitStreamFilter *bsf= first_bitstream_filter;
  32. while(bsf){
  33. if(!strcmp(name, bsf->name)){
  34. AVBitStreamFilterContext *bsfc= av_mallocz(sizeof(AVBitStreamFilterContext));
  35. bsfc->filter= bsf;
  36. bsfc->priv_data= av_mallocz(bsf->priv_data_size);
  37. return bsfc;
  38. }
  39. bsf= bsf->next;
  40. }
  41. return NULL;
  42. }
  43. void av_bitstream_filter_close(AVBitStreamFilterContext *bsfc){
  44. if(bsfc->filter->close)
  45. bsfc->filter->close(bsfc);
  46. av_freep(&bsfc->priv_data);
  47. av_parser_close(bsfc->parser);
  48. av_free(bsfc);
  49. }
  50. int av_bitstream_filter_filter(AVBitStreamFilterContext *bsfc,
  51. AVCodecContext *avctx, const char *args,
  52. uint8_t **poutbuf, int *poutbuf_size,
  53. const uint8_t *buf, int buf_size, int keyframe){
  54. *poutbuf= (uint8_t *) buf;
  55. *poutbuf_size= buf_size;
  56. return bsfc->filter->filter(bsfc, avctx, args, poutbuf, poutbuf_size, buf, buf_size, keyframe);
  57. }