static GstVaapiDecoderStatus gst_vaapi_decoder_jpeg_decode (GstVaapiDecoder * base_decoder, GstVaapiDecoderUnit * unit) { GstVaapiDecoderJpeg *const decoder = GST_VAAPI_DECODER_JPEG_CAST (base_decoder); GstVaapiDecoderStatus status; GstJpegSegment seg; GstBuffer *const buffer = GST_VAAPI_DECODER_CODEC_FRAME (decoder)->input_buffer; GstMapInfo map_info; status = ensure_decoder (decoder); if (status != GST_VAAPI_DECODER_STATUS_SUCCESS) return status; if (!gst_buffer_map (buffer, &map_info, GST_MAP_READ)) { GST_ERROR ("failed to map buffer"); return GST_VAAPI_DECODER_STATUS_ERROR_UNKNOWN; } seg.marker = unit_get_marker_code (unit); seg.data = map_info.data; seg.offset = unit->offset; seg.size = unit->size; status = decode_segment (decoder, &seg); gst_buffer_unmap (buffer, &map_info); if (status != GST_VAAPI_DECODER_STATUS_SUCCESS) return status; return GST_VAAPI_DECODER_STATUS_SUCCESS; }
/** * Writes a coap option from given string @p s to @p buf. @p s should * point to a (percent-encoded) path or query segment of a coap_uri_t * object. The created option will have type @c 0, and the length * parameter will be set according to the size of the decoded string. * On success, this function returns the option's size, or a value * less than zero on error. This function must be called from * coap_split_path_impl() only. * * @param s The string to decode. * @param length The size of the percent-encoded string @p s. * @param buf The buffer to store the new coap option. * @param buflen The maximum size of @p buf. * * @return The option's size, or @c -1 on error. * * @bug This function does not split segments that are bigger than 270 * bytes. */ static int make_decoded_option(const unsigned char *s, size_t length, unsigned char *buf, size_t buflen) { int res; size_t written; if (!buflen) { debug("make_decoded_option(): buflen is 0!\n"); return -1; } res = check_segment(s, length); if (res < 0) return -1; /* write option header using delta 0 and length res */ written = coap_opt_setheader(buf, buflen, 0, res); assert(written <= buflen); if (!written) /* encoding error */ return -1; buf += written; /* advance past option type/length */ buflen -= written; if (buflen < (size_t)res) { debug("buffer too small for option\n"); return -1; } decode_segment(s, length, buf); return written + res; }