avcodec/dca: return standard error codes in avpriv_dca_parse_core_frame_header()

This prevents making the DCAParseError enum part of the ABI.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Reviewed-by: foo86 <foobaz86@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
pull/272/head
James Almer 7 years ago
parent 2b739e1cb8
commit 3df4939988
  1. 11
      libavcodec/dca.c
  2. 12
      libavcodec/dca.h

@ -149,9 +149,14 @@ int ff_dca_parse_core_frame_header(DCACoreFrameHeader *h, GetBitContext *gb)
int avpriv_dca_parse_core_frame_header(DCACoreFrameHeader *h, const uint8_t *buf, int size) int avpriv_dca_parse_core_frame_header(DCACoreFrameHeader *h, const uint8_t *buf, int size)
{ {
GetBitContext gb; GetBitContext gb;
int ret;
if (init_get_bits8(&gb, buf, size) < 0) ret = init_get_bits8(&gb, buf, size);
return DCA_PARSE_ERROR_INVALIDDATA; if (ret < 0)
return ret;
return ff_dca_parse_core_frame_header(h, &gb); if (ff_dca_parse_core_frame_header(h, &gb) < 0)
return AVERROR_INVALIDDATA;
return 0;
} }

@ -46,7 +46,6 @@ enum DCAParseError {
DCA_PARSE_ERROR_RESERVED_BIT = -7, DCA_PARSE_ERROR_RESERVED_BIT = -7,
DCA_PARSE_ERROR_LFE_FLAG = -8, DCA_PARSE_ERROR_LFE_FLAG = -8,
DCA_PARSE_ERROR_PCM_RES = -9, DCA_PARSE_ERROR_PCM_RES = -9,
DCA_PARSE_ERROR_INVALIDDATA = -10,
}; };
typedef struct DCACoreFrameHeader { typedef struct DCACoreFrameHeader {
@ -211,10 +210,19 @@ int avpriv_dca_convert_bitstream(const uint8_t *src, int src_size, uint8_t *dst,
/** /**
* Parse and validate core frame header * Parse and validate core frame header
* @return 0 on success, negative DCA_PARSE_ERROR_ code on failure * @param[out] h Pointer to struct where header info is written.
* @param[in] buf Pointer to the data buffer
* @param[in] size Size of the data buffer
* @return 0 on success, negative AVERROR code on failure
*/ */
int avpriv_dca_parse_core_frame_header(DCACoreFrameHeader *h, const uint8_t *buf, int size); int avpriv_dca_parse_core_frame_header(DCACoreFrameHeader *h, const uint8_t *buf, int size);
/**
* Parse and validate core frame header
* @param[out] h Pointer to struct where header info is written.
* @param[in] gbc BitContext containing the first 120 bits of the frame.
* @return 0 on success, negative DCA_PARSE_ERROR_ code on failure
*/
int ff_dca_parse_core_frame_header(DCACoreFrameHeader *h, GetBitContext *gb); int ff_dca_parse_core_frame_header(DCACoreFrameHeader *h, GetBitContext *gb);
#endif /* AVCODEC_DCA_H */ #endif /* AVCODEC_DCA_H */

Loading…
Cancel
Save